This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes invoke js method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "invoke js method" Watch "invoke js method" New topic
Author

invoke js method

Piradharsan Navaratnam
Greenhorn

Joined: May 15, 2007
Posts: 14
In my form i have to invoke a js method before submit. So i added th below code to the submit button.

input type="submit"

onnclick="return jsmethod()"
---------I hv added nn becaz it is not allowing here---------

It is invoking the method when i click the submit button. But it is not invoking the js method when i press enter.

Why is that???

Its invoking the jsmethod() when i click submit button as well as on enter key press on all other forms except one form why???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56538
    
  14

Originally posted by Piradharsan Navaratnam:
I hv added nn becaz it is not allowing here
Please use real words when posting to the forums. Abbreviations such as "hv" in place of "have" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

Why is that???
In English, questions are terminated with a single question mark. Please refrain from using more than one to end such a sentence.

It is invoking the method when i click the submit button. But it is not invoking the js method when i press enter.

Why is that?
Because the Enter key has nothing to do with the submit button. Why would you expect a click handler for a button to be invoked without a mouse click?

If want to execute code on the submission of a form, rather than a specific triggering event such as a mouse click, declare an onsubmit handler for the form.
[ August 16, 2007: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: invoke js method
 
Similar Threads
Problem in invoking the action method
How to submit form with return
Button invisible problem
Pressing ENTER when Button is selected doesnt fire buttonActionPerformed...
JavaScript