Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:38:14+00:00 2026-06-01T05:38:14+00:00

We alert user using this javascript, now i want to add this functionality to

  • 0

We alert user using this javascript, now i want to add this functionality to my html form, which sends the data using the post method to my php form processing page.

Now what i want is to terminate the action if the user presses cancel button, it means all the data which has been sent using the post method should not be sent and the person would not be able to process the form until and unless he/she clicks the OK button. So is it possible? Or it is just some idiot question?

<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button!");
if (r==true)
  {
  alert("You pressed OK!");
  }
else
  {
  alert("You pressed Cancel!");
  }
}
</script>
</head>
<body>

<input type="button" onclick="show_confirm()" value="Show a confirm box" />

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:38:16+00:00Added an answer on June 1, 2026 at 5:38 am

    Call the confirm on form submit, not on button click, and change the button to a submit button:

    <form onsubmit="return show_confirm();">
        <input type="text" name="test" value="test"><br>
        <input type="submit" value="Show a confirm box">
    </form>
    

    Add a return false; if cancel has been clicked:

    function show_confirm() {
        var r=confirm("Press a button!");
        if (r===true) {
            alert("You pressed OK!");
        } else {
            alert("You pressed Cancel!");
            return false;
        }
    }
    

    Also see my example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If the user-agent includes the word myapp, then alert('hi'); BTW, I am using JQuery.
When you want to alert a user of something once (one time notes about
I want to alert the user that the session timeout is about to expire.
I'm using the Facebook JavaScript API to add 'like' buttons in an application. I've
I'm trying to show an alert when a user using IE6 uses my site.
I want to create a javascript which checks if a new rss feed has
I am not very comfortable using javascript so trying my hands to use this
I am Developing a Registration Form in ASP.NET in Which I am using client
In my document I have this script: $.ajax({ type:POST,url:ajax.php,data:data, success: function() { //onsuccess },
I have a small class that displays an alert via Javascript. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.