Jump to content
Saeed

Set focus to a text field after refresh

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...