Issue
In a form I have a button as input/submit. When I submit the value of the button is send.
if I change to input/button instead and do the submit via JQuery
i.e. $("form").submit()
the form is submitted but the value of the button is not send. Why? How could I fix this?
<form name="myform" id="myform" action="http://localhost/mypage.html" method="POST" >
<input type="button" id="btn" value="Actual value" name="save" >
</form>
$(document).ready(function() {
$("#btn").click( function() {
$("myform").submit();
}
}
Solution
Buttons are not the same as inputs--that's why the button doesn't add to the form submission. You could add an input of type hidden
with the value you want next to the button.
Otherwise you would have to use JavaScript to grab the button after the form has been submitted to get its value.
Answered By - haz0rd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.