trampolinejoe Posted February 16, 2009 Share Posted February 16, 2009 Hello Guys, I know this isnt php related its more html based, but can anybody tell me how to have a text box automatically selected when a page loads? I have looked at tabindex but it seems that tabindex is more for ordering the page rather then autoselecting. As in the flasher is already in the box ready to start typing. (refer to google as an example) Sorry if I asked this question in the wrong fourm Link to comment https://forums.phpfreaks.com/topic/145413-solved-automatically-selecting-textfield/ Share on other sites More sharing options...
haku Posted February 16, 2009 Share Posted February 16, 2009 Give your textarea an id like this: <textarea id="target"></textarea> And add this javascript to the head of your document. <script type="text/javascript"> window.onload = function() { document.getElementById('target').focus() } </script> Link to comment https://forums.phpfreaks.com/topic/145413-solved-automatically-selecting-textfield/#findComment-763375 Share on other sites More sharing options...
trampolinejoe Posted February 16, 2009 Author Share Posted February 16, 2009 Hey Man! Thanks that worked great! Link to comment https://forums.phpfreaks.com/topic/145413-solved-automatically-selecting-textfield/#findComment-763393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.