Sunday, September 15, 2013

[JavaScript] run javascript before submiting a form


<html>
<head>
<script>
function runAlert()
{
var path ="http://www.jup.com/img.jpg";
alert(path);
}
</script>
</head>
<body>
<form action="test.php" method="post" onSubmit="return runAlert()">
<input type=submit >
</form>
</body>
</html>
Set onsubmit within form tab, the example I have tested and work.
Run Javascript first, then will submit the form.


Reference: http://www.codingforums.com/showthread.php?t=126690

No comments :

Post a Comment