I am trying to process a form using Jquery and when Javascript is not available (or turned off) in the browser then it should be processed using PHP.
To do this, I've added action='php_file'
and onsubmit='myFunction();'
to the form tag.
What it should do:
- When JS is available:
alert("Success!");
- When JS not available: post data to getdata.php
But when I click on the submit button, the page goes to the PHP file after showing alert box.
You can see the page at http://cgpacalculator.in/
Edit: Here's the form code
<script>
function myFunction(){
alert("Success!");
}
</script>
<form method="post" action="getdata.php" id="calculator" onsubmit="myFunction();">
<!-- table here -->
<input class="myButton" type="submit" value="Calculate">
</form>
Any idea?
Thanks in advance :)