Hi there,
I've been trying to update the value of one textbox by using the onChange event when another textbox is modified. For now, I just want it to work so I'm trying to copy the exact value without any calculation, but for some reason it's not working. I suppose there's something wrong with my syntax, but I can't find it out. Here's the code:
This is just an example, but my page uses asp and creates a number of form fields so the names will vary. The error is somewhere in the "document.forms['paysheet']....." line but I've tried many different combinations and keep getting an object expected error. If I just use alerts all the numbers I want are passed properly into and throughout the function.
Any help would be greatly appreciated. Thanks!
Kevin
I've been trying to update the value of one textbox by using the onChange event when another textbox is modified. For now, I just want it to work so I'm trying to copy the exact value without any calculation, but for some reason it's not working. I suppose there's something wrong with my syntax, but I can't find it out. Here's the code:
Code:
<script language="Javascript">
<!--
function updateX4(original)
{
//The value of the field to update is always just 1 more than the incoming original variable
var toChange = new String(parseInt(original.name) + 1);
document.forms['pay'][toChange].value = original.value;
}
-->
</script>
<form name="pay" action="paycreate.asp" method="post">
<input type="text" name="1000" onChange="updateX4(this)">
<input type="text" name="1001">
</form>
This is just an example, but my page uses asp and creates a number of form fields so the names will vary. The error is somewhere in the "document.forms['paysheet']....." line but I've tried many different combinations and keep getting an object expected error. If I just use alerts all the numbers I want are passed properly into and throughout the function.
Any help would be greatly appreciated. Thanks!
Kevin