views:

199

answers:

3

Hi, How can I place the cursor automaticly to certain input box. This would help to not use the mouse all the time when open the page. (php and html)

Thank you!

A: 

Use the focus() method of the input on body.onLoad.

Ignacio Vazquez-Abrams
A: 
window.onload = function(){
   document.getElementById("InputBoxID").focus();
};
S.Mark
+6  A: 
<input name="input1" id="input1" value="" />

window.onload = init;

function init(){
document.getElementById("input1").focus();
}

This should do

c0mrade
you should keep your opening brace on the same line as the function init()
Matt Joslin
I should indeed, but this way it looks easier to handle when dealing with large chunks of code, anyways I fixed it :)
c0mrade
c0mrade: What was up with your other answer? Why was it deleted?
Pekka
Umm it was deleted because it was duplicate, I don't even know why there were 2 posts, I only wrote one .. they must have had some kind of glitch with the website at that time .. Jeff himself deleted it, maybe they figured out what was the prob.
c0mrade