how to set default submit button in jsp?
I have a jsp page that has 5 submit buttons on it all associated with a
single form.
The problem is that the if i hit enter (to process the form) the submit button that is selected should be the 1st one as per requirement.
Im using Struts frame work and LookupDispatchAction.
Is there anyway to set a default submit button for a page?
Thanks in advance..
# 1
> The problem is that the if i hit enter (to process
> the form) the submit button that is selected should
> be the 1st one as per requirement.
You'd probably need to use JavaScript, not Java, to trap the enter key event, and do something with it:
<script >
if(event.keyCode == 13) { // 'Enter' event
// do something
}
</script>
# 3
[nobr]Also, keep in mind that changing the tabIndex, as suggested on some forums, doesn't make a difference. As BalusC said, it's the first button in the perspective that is clicked.
And another point, one I'm not very clear about. If there is only one text field on the form and you press Enter while typing in it, the value of the submit button on the form is not sent with the form fields. You could say that the default submit button is not clicked at all. If, however, there is a second text field ( not a second input field, but specifically a text field ) and you press Enter while any of the textfields has focus, the default button will be clicked.
You can try out this simple HTML/JavaScript code to verify that. Just add/remove whichever fields you want to check out.
<html>
<body>
<form>
<input type="radio" />
<select>
</select>
<input type="text" />
<input type="text" />
<br/>
<input type=submit tabindex=1 value=2 onclick="alert('2');"/>
<input type=submit tabindex=99 value=1 onclick="alert('1');"/>
</form>
</body>
</html>
[/nobr]
# 4
Thanx 4 the response...
well i've already tried out with rearranging buttons..it's not working!!! N one more problem is tat im not supposed to use java script at all :-( !!!!
Have u taken a note that im using LookupDispatchAction.... so im unable to set a default parameter even....so is there any other go... but the happy thing is that im able to do this using DispatchAction...
So pls help me if any go, using LookupDispatchAction....
Thanx..
# 5
Thanx 4 the response...
well i've already tried out with rearranging buttons..it's not working!!! N one more problem is tat im not supposed to use java script at all :-( !!!!
Have u taken a note that im using LookupDispatchAction.... so im unable to set a default parameter even....so is there any other go... but the happy thing is that im able to do this using DispatchAction...
So pls help me if any go, using LookupDispatchAction....
Thanx..