I am trying to add a button to my form, which essentially runs some other php code than my usual form submission code, which, instead of sending me the form, converts my page into a good pdf, ready to print. Everything works for me, except that pressing a button leads to an error.
Firebug says:

Here is the code:
<form id="adaugareanunt" name="adaugareanunt" action="mailerPDF.php" method="post">
<table width="535" border="0" cellspacing="2" cellpadding="3">
<tr class="TrDark">
and for the button:
<div style="text-align:right"><img src="images/print-button.png" onClick="chgAction()" width="60px" height="20px"></div>
using script:
<script language="JavaScript" type="text/JavaScript">
function chgAction()
{
document.getElementById["adaugareanunt"].action = "mailerXFDF.php";
document.getElementById["adaugareanunt"].submit();
document.getElementById["adaugareanunt"].action = "mailerPDF.php";
}
</script>
source
share