Solved

Javascript, Upon submit, ask to confirm "Yes" or "No", if Yes the proceed.

Posted on 2010-09-09
5
750 Views
Last Modified: 2012-05-10
Assume
<INPUT TYPE="submit" NAME="deleteOldEntries" VALUE="Delete all">
<input type=text name="mydate">

If submit button is press, show a popup to confirm deletion.  In message, display value from "mydate" text field.  If select yes, then proceed with the submit, otherwise, do nothing.
0
Comment
Question by:rgbcof
5 Comments
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 33634864
<script>
  function ex()
  {
 var r=confirm("Press a button"+document.getElementById("mydate").value);
if (r==true)
  {
  alert("You pressed OK!");
  }
else
  {
  alert("You pressed Cancel!");
  }

  }
  </script>

 </HEAD>

 <BODY>
  <INPUT TYPE="button" NAME="deleteOldEntries" VALUE="Delete all" onclick='ex()'>
<input type=text id="mydate" value='12-12-2008'>
If submit button is press, show a popup to confirm deletion.  In message, display value from "mydate" text field.  If select yes, then proceed with the submit, otherwise, do nothing.

 </BODY>
</HTML>
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33634873
<INPUT TYPE="button" NAME="deleteOldEntries" VALUE="Delete all" onclick="submitForm()">

function submitForm()
{
    if (confirm("Do you really want to delete it?") )
    {
        document.forms[0].submit();
    }
}
0
 
LVL 10

Accepted Solution

by:
bugada earned 63 total points
ID: 33635456
<html>
<head>
   <scrip type="text/javascript">
      function confirmSubmit(form) {
          return confirm("Are you sure to delete all "+form.mydate.value + "?");
      }
   </script>
...

<form name="theform" onSubmit="return conformSubmit(this)">
   <input type="submit" name="deleteOldEntries" value="Delete all">
   <input type=text name="mydate">
</form>

...
<html>
0
 
LVL 15

Assisted Solution

by:StealthyDev
StealthyDev earned 62 total points
ID: 33635655
Hi, try this:
<form name="frmname" onsubmit="return(confirm('Are you sure want to delete: ' + document.frmname.mydate.value + '?'));">
  <INPUT TYPE="submit" NAME="deleteOldEntries" VALUE="Delete all">
  <input type=text name="mydate">
</form>

Open in new window

0
 

Author Closing Comment

by:rgbcof
ID: 33641916
Both ways work. Thank you,
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now