|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a page with two submit buttons. Is there a way to use the focus() function to place focus on the second button instead of the first (default)? Here are what the tags look like:
<INPUT TYPE="SUBMIT" VALUE="Previous" NAME="BUTTON"> <INPUT TYPE="SUBMIT" VALUE="Continue" NAME="BUTTON"> The Name of the buttons need to be the same (this is in CGI program I'm writing to create this page. I check to see which button is pressed by the value.). I've tried the following in the Body onload event: document.forms[0].BUTTON[1].focus() but it didn't seem to work. Thanks for any help you can give. Troy |
|
#2
|
|||
|
|||
|
I don't think the problem is your statement, but rather how you named your buttons. The name simply gives the button a label. It is not an array variable which is how you're trying to use it in your JS statement. Simply name each button uniquely, ie:button1 and button2. Then rewrite your JS statement to say:
document.forms[0].button2.focus() you could also use: document.forms[0].element[x].focus() where 'x' is the array number of the button element. Since an element is anything, ie: link,button, checkbox, etc., you would determine the number of the element by counting (from 0) the location within your source code, not where it appears on the page. But I find this more confusing than using a name. Russ |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Place focus on input type submit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|