my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes HTML +Javascript submit query?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML +Javascript submit query??" Watch "HTML +Javascript submit query??" New topic
Author

HTML +Javascript submit query??

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
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


Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
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.


Manesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML +Javascript submit query??
 
Similar Threads
How to submit struts form based on user confirmation through javascript
java script
form being submitted twice
buttons cannot work properly by using Firefox 1.5
Limit on Data/Key-Value Pairs in Form Submission