clang Posted October 14, 2007 Share Posted October 14, 2007 I know this is probably a stupidly simple question, so I'm sorry in advance. I've tried looking around here and google to find a solution but came up empty handed. May my google-foo is not what it used to be. Basically I have a form, made in html, with PHP processing it. I would like the first text box on the page, to be selected on page load, so that I start typing right away, with out having to use my mouse to click on the text box to place the cursor inside it. Suggestions? Quote Link to comment Share on other sites More sharing options...
clang Posted October 14, 2007 Author Share Posted October 14, 2007 I continued looking and found something a bit helpful: http://www.htmlgoodies.com/beyond/javascript/article.php/3471131#code for those that are interested. But this requires me to include the name of that object, in this case a text box, in the body. Is there another way to handle this? I ask because all of my pages call a php function to get the body and the name of that text box has the need to be different on various pages. maybe a this.focus() in the <input> tag? Quote Link to comment Share on other sites More sharing options...
clang Posted October 14, 2007 Author Share Posted October 14, 2007 Ha! Thanks everyone I kept looking and figured it out. For anyone that needs to know this, another option to onload is the following <script type="text/javascript"> document.form.item.focus(); </script> Where form is the name of your form, and item is the name of the object you would like highlighted first. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.