Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML +Javascript submit query??

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my application i have taken a submit button in my html form but it gets submitted when the button is CLICKED that is i have kept a onClick event on that button & the type of button is "button" not "submit" because if i keep it as submit then some problem arises in my application thats when i click on that button using mouse the form gets submitted 2 times.

So what i want to do is i want to keep this onclick event active but if the user presses enter key then also the function called on onClick event should get called..

So how to do this thing??


Thanks,
Jignesh
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though I partially understood you question, you can use onsubmit event handler of the form tag.

You need to use the "submit" button and you need to write the function to handle the onsubmit event of the form. So in both the cases (click of submit button or enter key) will trapped. On the event handler, if you dont want the form to get submitted, you can return false from the event handler.

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic