Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

confirm submit then disable button

Posted on 2006-05-24
5
Medium Priority
?
330 Views
Last Modified: 2008-03-04
Hi all,

Simple question. I know how to disable a submit button when clicking a button in a form but I want to disable it AFTER a confirm statement.  Seems simple enough. A confirm isa true false response so how would I disable on true?


<script LANGUAGE="JavaScript">
<!--
function OrdSubmit()
{
var sagree=confirm("Click OK if you want to submit this order?");
  if (sagree)
    document.orderSubmit.Subutton.disable = true;
    document.orderSubmit.submit();
  else
    return;
}
// -->
</script>

<form name="orderSubmit" method="POST" action="" id="orderSubmit">
   <input type="button" ID="Subutton" name="Subutton" value="Submit" onclick="OrdSubmit(this.form)">
</form>
0
Comment
Question by:binovpd
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
basicinstinct earned 200 total points
ID: 16757301
Is this what you are trying to do?

<script LANGUAGE="JavaScript">
<!--
function OrdSubmit()
{
  var sagree=confirm("Click OK if you want to submit this order?");
  if(sagree)
  {
    document.orderSubmit.Subutton.disabled = true;
  }
  return sagree;
}
// -->
</script>

<form name="orderSubmit" method="POST" action="" id="orderSubmit">
   <input type="submit" ID="Subutton" name="Subutton" value="Submit" onclick="return OrdSubmit();">
</form>
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 16757306
In fact I'd do this:

function OrdSubmit()
{
  var sagree=confirm("Click OK if you want to submit this order?");
  document.orderSubmit.Subutton.disabled = sagree;
  return sagree;
}
0
 

Author Comment

by:binovpd
ID: 16762011
Thanks basicinstinct.
0
 

Author Comment

by:binovpd
ID: 16762122
Ont thing however. It needs to post the form after disabling the button.  Not just disable the button. Thats what I was having problems with
0
 

Author Comment

by:binovpd
ID: 16762152
Like so

var sagree=confirm("Click OK if you want to submit this order?");
  if(sagree)
  {
    document.orderSubmit.Subutton.disabled = true;
    document.orderSubmit.submit();
  }
  return sagree;
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

810 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