Click to See Complete Forum and Search --> : Using a varaiable command


them
11-29-2002, 07:08 AM
Hello,

Does anybody know if it is possible to use a variable command in JavaScript. I want to use it to set the focus back on the field that is leaves when i update my page. I have used this command:

document.form1.text1.focus();

to set the focus on textbox 1 on form 1. But the names of the textboxes are different every session. So i have to replace the text1 with a variable.

I hope that somebody could help me with this?

gil davis
11-29-2002, 08:19 AM
document.form1["text1"].focus();

or

var which = "text1";
document.form1[which].focus();