<form action="fake_action" method="POST"> <button name="disable" value="Deactivate Account" type="submit" onclick="click();">Deactivate Account</button> </form>
For the above form, the name/value pair for the submit button should be included in the data set when the form is submitted (i.e., the submit button is clicked). When I run the above form in Safari, the server app doesn't get
NAME VALUE disable Deactivate Account
in the form data. However, if I remove the onclick event in the submit button control, the server app get the data I expect.
UPDATE:
Here is the link to the standalone test
it is a simple form with 4 different kinds of submit buttons, and here is the source code for the html page
<html> <head> <title>A simple form</title> <script type='text/javascript'> function test(){ document.forms[0].submit(); } </script> </head> <body> <form action="formsubmit.php" method="POST"> <input name="disable1" value="Deactivate Account(submit button with onclick)" type="submit" onclick="test()"> <input name="disable2" value="Deactivate Account(submit button w/o onclick)" type="submit"> <button name="enable1" value="Activate Account(submit push button with onclick)" type="submit" onclick="test();">Activate Account(submit push button with onclick)</button> <button name="enable" value="Activate Account(submit push button w/o onclick)" type="submit">Activate Account(submit push button w/o onclick)</button> </form> </body> </html>
here is the source code for formsubmit.php, which simply print out the successful control sent to the server (any one of those submit buttons)
<html> <head> <title>Submit Form</title> </head> <body> <?php foreach ($_POST as $item) { print $item; } ?> </body> </html>
basically, I only get successful control for those submit buttons without onclick event handler, which does nothing, but call the form submit method in this test case, while I got all submit buttons in Firefox.
No comments:
Post a Comment