Link to home
Start Free TrialLog in
Avatar of binovpd
binovpd

asked on

confirm submit then disable button

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>
ASKER CERTIFIED SOLUTION
Avatar of basicinstinct
basicinstinct
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
}
Avatar of binovpd
binovpd

ASKER

Thanks basicinstinct.
Avatar of binovpd

ASKER

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
Avatar of binovpd

ASKER

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;