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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referencing a dynamically created textbox

Status
Not open for further replies.

Gaff

Programmer
Dec 13, 2001
30
0
0
IE
I am creating textboxes based on details that i get from a cookie.They are being created dynamically by using a "document.write" statement.The name of the textboxes all begin with "text" and i am appending on number based on a variable called num which i'm using to loop through the cookie after i split it eg for num = 1 the text box name is "text1".

Now the problem is that i want to reference the value of the textbox and compare it to the value in the cookie. to do this i was going to loop through the cookie using the num variable again and since a split part of the cookie will correspond to a textbox with the name "text" + num i wanted to simply get the value from the textbox after it has been modified on the form.

I tried the following:

var amt;
amt = window.document.CForm.text + num + .value ;

the scope of num is fine but is it possible to incorporte variables into this type of request??? Any help will be grealy appreciated. Thanks
Ricky
 
you can use eval to incorporate variables in any command.

i.e
amt = eval("window.document.CForm.text" + num +".value");

eval can be used to incorporate variables on the left hand side of command.

i.e
eval("window.document.CForm.text" + num +".value") = "xyz"

-Dalip
 
thanks that worked fine!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top