kevinritt Posted December 17, 2008 Share Posted December 17, 2008 I'm not sure how this can be done but I have a form to enter data into a database. Is there a way to have the cursor go to the first text field when the page is opened? Thanks Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/ Share on other sites More sharing options...
Maq Posted December 17, 2008 Share Posted December 17, 2008 <br /> document.myform.myinput.focus();<br /> Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/#findComment-718112 Share on other sites More sharing options...
glenelkins Posted December 17, 2008 Share Posted December 17, 2008 yep, try this in your header code: <script type="text/javascript"> window.onload = function() { document.FORM_NAME_HERE.FIELD_NAME_HERE.focus(); } </script> Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/#findComment-718115 Share on other sites More sharing options...
phpian Posted December 17, 2008 Share Posted December 17, 2008 not with php. javascript can. give that form element an id, then attach an onload event and use: document.getElementById('inputid').focus(); or what Maq said Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/#findComment-718116 Share on other sites More sharing options...
kevinritt Posted December 17, 2008 Author Share Posted December 17, 2008 I'm new here but I gotta tell ya - the responses and help here have been outstanding. I have never had such timely response from a forum - thank you Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/#findComment-718212 Share on other sites More sharing options...
Maq Posted December 17, 2008 Share Posted December 17, 2008 Yeah I know. Whenever I take the time to answer a topic, someone else has usually beaten me there! Link to comment https://forums.phpfreaks.com/topic/137426-have-curser-go-to-firs-form-field/#findComment-718224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.