Click to See Complete Forum and Search --> : javascript:this.blur() allowing the user to type an amount


jpipitone
July 24th, 2007, 10:35 PM
I have a form that I'm using with authorize.net that automatically populates based on the user's selection. There are 3 options which I will show below.

I want the user to be able to pick from the 3 amounts, but when they select "Just a donation," I want the form field x_amount to be editable. It is a simple text field in which they can type the amount they'd wish to donate, rather than selecting from a list of options.

My option values are as follows:

<select name="x_starfish" onChange="this.form.x_Amount.value=this.options[this.selectedIndex].value">
<option value="">Just a donation
<option value="15.00">$15 Per Month
<option value="25.00">$25 Per Month
<option value="35.00">$35 Per Month
</select>
On the x_amount field, this is how it looks:

<input name="x_Amount" type="text" onFocus="javascript:this.blur()" size="7" />
I am wondering if the this.blur() function is stopping me from allowing the user to edit that field. Can anyone help? Is there another function that I can call which allows the user to type in a manual donation amount if they choose not to select a pre-set amount from my drop down list?

I appreciate your help and feedback. This one has stumped me.

PeejAvery
July 25th, 2007, 07:57 AM
A couple of things...

1. You must close the <option> tag.

2. This refers to the object calling it so you don't need the selected index. Also it is incorrect to call this and then another form element. Use document.formname for that. Notice the changes to onchange that I made.

<select name="x_starfish" onchange="document.form.x_Amount.value=this.value">
<option value="">Just a donation</option>
<option value="15.00">$15 Per Month</option>
<option value="25.00">$25 Per Month</option>
<option value="35.00">$35 Per Month</option>
</select>
3. All events are already JavaScript, so supplying "javascript:" in front will produce an error or incorrect results.

<input name="x_Amount" type="text" onfocus="this.blur()" size="7" />