If I have a form which have 2 buttons , and when I click Button1 then it will be action="submit1.php" , if Button2 then action="submit2.php".
I tried this:
<script language="javascript">
function Button1()
{
document.Form1.action = "submit1.php"
document.Form1.target = "iframe1";
document.Form1.submit();
}
function Button2()
{
document.Form1.action = "submit2.php" ;
document.Form1.target = "iframe2";
document.Form1.submit();
}
</script>
Somewhere in the <body>:
<div style="visibility:hidden">
<iframe NAME="iframe1" WIDTH="40" HEIGHT="40"></iframe>
<iframe NAME="iframe2" WIDTH="40" HEIGHT="40"></iframe>
</div>
And in the form:
<form name="Form1" id="Form1" method="post">
<input type="submit" name="Button1" onclick="Button1();">
<input type="submit" name="Button2" onclick="Button2();">
</form>
It’s not working , am I make anything wrong?
Thank you.
You have two issues
EITHER
change the buttons to type=”button”
OR
remove the submit from the functions
Plain JS (using the simpler forms access):
Unobtrusively (recommended):