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

Document Object Question

Status
Not open for further replies.

alshebli

Programmer
Feb 22, 2005
10
US
hi! :)

i have a question. So here's the situation, i have an html file with a form. I have named the text inputs in the form, 'First1', 'First2', First3', .... since you don't know how many first names you can have. you can keep generating them.

Anyway, that's not my problem. In order to keep generating these inputs, I'm using javascript. So somewhere in the script i have the following:

eleInput1.setAttribute('name','First' + cnt);
eleInput2.setAttribute('type','text');

now i was to implement the onfocus attribute to it as follows:

eleInput1.onfocus = function () { setfound(this.form.First+cnt); }

However I obviously cannot write First+cnt above. I tried concatenating a string variable and adding that, but that didn't work. I also tried:

eleInput1.onfocus = function () { setfound(this.form.elements['First'+cnt]); }

And that didn't work as well.

Any suggestions???

Thank you! :)
 
Try this:

eleInput1.onfocus = function() { setfound(this); }

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top