Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable question 2

Status
Not open for further replies.

aperfectcircle

Programmer
Apr 3, 2001
290
US
In something like [red]document.form1.fieldname.value = "text"[/red], is there any way to set "fieldname" from a variable?
 
yes, make the variable you want containing the field name, then do this:

eval("document.form1." + fieldname + ".value = 'text'"); -Greg :-Q

flaga.gif
 
what about this?

var name="fieldname"
document.form1[name].value = 'text'

(so, name is a string & might be passed from somewhere..) Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top