Click to See Complete Forum and Search --> : setting the value


Harman
10-19-2005, 10:18 AM
why is this not working

eval('document.'+formName+'.'+fieldName+'.value = '+doWhat);

where formName = 'myForm'; //which is the name of the form
fieldName = 'act'; //its the name of the field in myForm
doWhat = 'getData'; //what is want the value of the field to be

Thanks

Kor
10-19-2005, 10:34 AM
avoid eval() method, use square brackets notation instead

what about:

document.forms[formName].elements[fieldName].value=doWhat;

On the other hand, the evaluation is not an assignment

Harman
10-19-2005, 11:02 AM
thanks