Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  189] [ 6]  / answers: 1 / hits: 80057  / 12 Years ago, sat, march 3, 2012, 12:00:00

I currently have a textbox in my aspx:



 <input type=text id=myTextbox  value= />


I was wondering if I could set the focus (put my cursor in that text box) every time my JavaScript method is called. I was hoping it would work along the lines of this:



function setFocus() {
document.getElementById(myTextbox).Focus();
}


Any suggestions?


More From » focus

 Answers
18

Invoke the lowercase .focus() function:



function setFocus() {
document.getElementById(myTextbox).focus();
}

[#87070] Thursday, March 1, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
claudiofredye

Total Points: 583
Total Questions: 101
Total Answers: 115

Location: Sao Tome and Principe
Member since Wed, Dec 29, 2021
2 Years ago
;