www.webdeveloper.com
Results 1 to 2 of 2

Thread: Using a varaiable command

  1. #1
    Join Date
    Nov 2002
    Posts
    1

    Exclamation Using a varaiable command

    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?

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    document.form1["text1"].focus();

    or

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles