Change the form and submit the form

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: enter image description here

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">
         //... more form code

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>
+4
source share
4 answers

Adaugareanuntis the key of the object :
getElementById["adaugareanunt"]

"Adaugareanunt" - line passed to method getElementById() :
getElementById('adaugareanunt')

+2
source
document.getElementById["adaugareanunt"]

change to

document.getElementById("adaugareanunt")
+8
source

: []

:()

.

var ar = newArray( " a " , " b " ) ; 
var ar = [ " a " , " b " ] ;
0

<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>
0

All Articles