htmlccgi-bin

Have password field and a next button displayed via c/cgi-bin/html. I want the focus to be in the password field when screen is displayed


Initial screen

a user logging into the displayed screen has to press tab or click in the password field to get to the password field and type the password. I want to hav focus in the password input box when the screen is displayed so that the user can immediately type the password.

I am using a cgi form in c with the HTML/cgi-bin command and the password line is defined with: These along with other code not relevant to the problem results in the attached screen being displayed. I have found out how to preset a radio button selection and a checkbox but have not found how to give focus to a password or text field on display of the screen. The fact that I can get there with a tab indicates that the focus is somewhere, just not where it needs to be. Anyone able to help? As is probably obvious I have been using these sorts of commands for only a short time but learn quickly. So please do not flame me for my ignorance.


Solution

  • <script type="text/javascript">document.getElementById("HTMLElementID").focus();</script> where HTMLElementID=id of the field in the form (you must insert id="..." on the field in the form)

    Put this before closing the body tag of the page.