Page 1 of 1

confirm button

Posted: Sat Apr 17, 2010 5:46 pm
by gammaman
I have this button that when clicked executes an oracle statement that starts a new data page. How can I have a confirm button in javascript (I know php does not really do confirm buttons) that sends a value to my button to know weather or not to execute the oracle statement. I cannot put the php code that contains the execute inside the javascript because javascript is client side and the oracle will be ignored.

Re: confirm button

Posted: Sun Apr 18, 2010 7:58 am
by solid
You add a function in the page HEAD like this:

Code: Select all

<script type="text/javascript">
function validateForm()
{
   var r=confirm("Are you sure?");
   if (r==true)
   {
      return true;
   }
   return false;
}
</script>
Then you add an onSubmit attribute to your form tag (note that the HTML char after javascript is a colon):

Code: Select all

<form id="myForm" name="myForm" action="/" method="POST" onsubmit="javascript:validateForm();">