Hi,
Im trying to make a script which will increment a text form field value by 1 each time a button is pressed.
Here is my code so far:
=======================
<SCRIPT language="JavaScript">
function function1(afield){
var var1 = afield;
var val1 = eval("form1."+var1+".value"
var result = val1 + 1;
eval("form1."+var1+".value"
= result;
}
</SCRIPT>
<form name=form1>
<p> </p>
<p> </p>
<p> </p>
<input type=text name=field1 value=-2 size="4"><input type=submit value=Work onclick="function1('field1');">
</form>
==================================
This script has errors... does anyone know how i can modify the field value without causing the error 'cannot assign to a function result'
Any help would be greatly appreciated!
Thanks
Im trying to make a script which will increment a text form field value by 1 each time a button is pressed.
Here is my code so far:
=======================
<SCRIPT language="JavaScript">
function function1(afield){
var var1 = afield;
var val1 = eval("form1."+var1+".value"
var result = val1 + 1;
eval("form1."+var1+".value"
}
</SCRIPT>
<form name=form1>
<p> </p>
<p> </p>
<p> </p>
<input type=text name=field1 value=-2 size="4"><input type=submit value=Work onclick="function1('field1');">
</form>
==================================
This script has errors... does anyone know how i can modify the field value without causing the error 'cannot assign to a function result'
Any help would be greatly appreciated!
Thanks