• 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
  • Paul Clapham
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

HTML +Javascript submit query??

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Master Gardener Program
https://coderanch.com/t/771761/Master-Gardener-Program
reply
    Bookmark Topic Watch Topic
  • New Topic