|
Store Form Focus As Variable?
Is it possible to store the current focus of a form in a variable (preferably PHP, but I am open to using JavaScript if necessary), so that, when the page reloads, the cursor will automatically be placed in the next form field?
I am working with a semi-complicated reporting application I wrote in PHP, using SQL. When the user chooses certain information from form fields, the form is submitted in order to fill in other fields properly and reloads the page with the new information in the form. I would like to have the focus set automatically on the next form field when the page reloads.
In other words, let's say I have 5 form fields in my form. When a user selects a month from form field 2, the form is submitted, reloading the page, and fills in form field 3 (which is a select box) with the number of days in that month, so that the user won't select an invalid option. I would like to automatically set the focus, on the event that form field 2 changes and causes the page to submit, to form field 3. I am assuming that the easiest way to do this is to figure out which form field the user last interacted with, and then add 1 to that number and set that as the focus when the page loads again.
Any suggestions? Any resources for me to look at? I've tried Googling, but I'm not 100% sure what to Google for in this case. I've never even seen a form that does this, personally, so I don't even have any examples to look at.
__________________
I hate Internet Explorer! Anyone with me?
|