• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Submit button problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys..

i have two submit buttons in my jsp and when i clicked on the ENTER key always it's taking the first submit button which i dont wont. Can i put any default submit button in the jsp.
Can you guys help me please.

Thanks in advance.
 
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Go thru below mentioned code, you will understand use of focus() method.



Thanks
vj
 
madoori Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

This is not i am looking for.Even in the example which you have given is also taking the first submit button. i.e after entering some text if i hit ENTER key it's taking the first SUBMIT button but i want to use the second button as DEFAULT. I want the submit button to be applied irrespective of its index.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's just the way things work. If that's not what you want, don't put two submit buttons in the form.
 
vijay dadhwal
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i have changed the code a bit, now go thru it to see how pressing enter key on text field trigger submit button 2 instead of defaut submit button 1.

Hope this help. Here is the code:-

<html>
<head>
<script language="javascript">
function show(value)
{
alert(value.value);
}
function activate()
{
if (event.keyCode == 13)
{
document.form1.s2.click();
}
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="feed" onkeypress="activate()">
<input type="submit" name="s1" value="Submit-1" onclick=show(this)">
<input type="submit" name="s2" value="Submit-2" onclick="show(this)">
</form>
</body>
</html>

Regards
vj
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That would mean establishing the key press handler for each and every field. Rather messy!

A much easier solution is to have one submit button that will be the "default" button. Make the other button of type "button" and use a click handler to cause it to submit the form just as if it were a submit button.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic