I am trying to send a form on page load using java, but the only thing I get is a form that isn't submitted and the page is redirected to the action address Form code <form name="vote" action="http://www.mysite.com/vote.php" method="POST"> <input type="submit" name="vote" value="1" > <input type="submit" name="vote" value="Vote1" > </form> Code (markup): I used <body onLoad="document.vot.submit()"> but it doesn't work
Actually, i didnt get your question in the corect sense. Can you explain it somewhat clearly. why you are using two submit buttons ? Also i think , it should be document.forms["vote"].submit();
How can this form be submitted when the page loads? <form name="vote" action="http://www.mysite.com/vote.php" method="POST"> <input type="submit" name="vote" value="1" > <input type="submit" name="vote" value="Vote1" > </form> Code (markup): The form needs some modifications
the form is wrong? you can't have 2 submits. remove one and it will work. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>test</title> </head> <body> <?=print_r($_POST)?><br /> <form name="vote" action="autosubmit.php" method="POST"> <input type="submit" name="vote" value="1" > </form> <script type="text/javascript"> window.onload = function() { document.forms['vote'].submit(); } </script> </body> </html> PHP:
May be delete one submit button. The php file isn't present in the location. Yes this is what happens on submit. The page is redirected to the action parameter and the element values in the form are passed along with them. Action specifies where to send the form-data when a form is submitted.
Yes , you can use two submit buttons. But have to identify which was pressed. You can use the follwing code.
its a bad form anyway -> cant all be name="vote", inclusive of the form itself, especially since he does not assign ids... when this is not driven by an event such as a mouse click - you are calling the form's submit method and that needs to 'pick' between two the submits?
it's possible to have 2 buttons and its possible to determine which one was clicked on by the click event. BUT it is NOT possible to use the form .submit() method and get it to decide which button to click instead. does that make sense why the auto submit fails?