Cannot update form field
Hi,
I'm trying to update a form field based on user input from a drop-down box. All the calculations are working but I can't get the final answer into a text field.
I've got five sets of fields, each is prefixed NC1, NC2, etc:
<td bordercolor="#F3ECDC"><select name="NC1Proof" id="NC1Proof" onblur="calc()">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select> </td>
<td bordercolor="#F3ECDC"><input name="NC1Amount" type="text" id="NC1Amount" value="0.00" size="10" maxlength="10"></td>
My JS code:
function calc(){
var NCProof = new Array();
var i;
var tmpAmt;
var FieldName="NC1Proof";
var x=document.getElementById(FieldName);
for (i=1;i<=5;i++)
{
FieldName = "NC" + i + "Proof";
x=document.getElementById(FieldName);
NCProof[i] = x.value;
FieldName = "NC" + i + "Amount";
tmpAmt=0;
if (NCProof[i] == "Yes") {
tmpAmt = 25; }
document.getElementByID(FieldName).value = tmpAmt; //this line fails
}
}
What am I missing that I can't update the NCxAmount field?
Thanks,
Westley
Hi, Try changing document.getElementByID(FieldName).value = tmpAmt; to document.getElementById(FieldName).value = tmpAmt; ... a lowercase "d".
Mike
Thanks Mike!
That did it. Not sure if I typed it that way or if I copied it from a script I found online, but all is working well now.
Thanks again,
Westley
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks