Jump to content

Set focus to a text field after refresh


Saeed

Recommended Posts

Good Day and Happy New Year. I'm trying to set the focus to a text field with this code:<body onLoad="document.formname.fieldname.focus();"> // (sorry, inserting the Codebox generated Invalid Argument in ips_text_editor.js.)<A name=OLE_LINK1>It kind of works! The focus is in the field, but not the cursor. That is, I don't see the I-beam in the field, but when I type a value, it appears there.The value entered in the field is then used to search for a database by clicking a button.And now the questions:1. Why is the cursor not blinking in the field although it has the focus?2. If the search returns a value (it is displayed outside of the field), the focus is lost. I tried putting the same code as above in the onClick event of the button, something like this:<input type="button" onClick="doWork();"><script> function doWork () { do the search; document.formname.fieldname.focus(); } </script> The script is within the <head> tags. The search works, but the focus is not set back to the field. How can I re-set the focus?3. If the page is reloaded, the focus is lost. Again, how to re-set it to the filed. Thank you for your help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...