I have decleared a function by Javascript before body of my page:
Code:
<script type="text/javascript">
<!-- Hide the script
function warn_on_submit()
{
var msg = "Are you sure, Dude????";
if (confirm(msg))
location.replace('update.php');
else
location.replace('java.php');>";
}
// end hiding -->
</script>
I have a form inside my PHP and I want to call my JavaScript function when onClick event is occured:
PHP Code:
print "<form method='POST' action='update.php' name='form1'>";
print "<input type='hidden' name='unique_id' value='{$unique_id}'>";
print "<input type='submit' value='update' onClick='warn_on_submit();'>";
print "</form>";
But when I submit the form I don't see any message asking for confirmation.
I am quite new to Javascript so excuse me if it was a stupid question