yes no cancel button in javascript

  • akaash
  • Beginner
  • Beginner
  • akaash
  • Posts: 62
  • Loc: Gujurat,India

Post 3+ Months Ago

In a form i am having a submit button.

I want to open a yes/no/cancel box when user presses this button.
If user selects yes then submit the form data else do not submit and remain on same page.

how do i do this in javascript?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

confirm("message to user") brings up the dialog box your looking for,
Basic example of usage.
Code: [ Select ]
<html>
<head>
<script language="javascript">
function getPermission(form){
    if(confirm("press ok to submit")){
        form.submit();
    }
}
</script>
</head>

<body>
<form action="postTo.asp" onSubmit="return false;">
<input type="submit" onClick="getPermission(this.form)">
</form>

</body>
</html>
  1. <html>
  2. <head>
  3. <script language="javascript">
  4. function getPermission(form){
  5.     if(confirm("press ok to submit")){
  6.         form.submit();
  7.     }
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <form action="postTo.asp" onSubmit="return false;">
  13. <input type="submit" onClick="getPermission(this.form)">
  14. </form>
  15. </body>
  16. </html>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 34 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.