javascript - HTML form method post does not work with multiple submit -



javascript - HTML form method post does not work with multiple submit -

html form method post not work multiple submit

i have following

<form id="myform" method="post" action=""> <select name="select_data"> <option value="1000">account demo 1</option> <option value="1035">account demo 2</option> </select> <input type="submit" onclick="sendform('<?php echo $domainurl;?>page_1')" form="myform" class="btn btn-primary btn-sm" value="page 1"> <input type="submit" onclick="sendform('<?php echo $domainurl;?>page_2')" form="myform" class="btn btn-primary btn-sm" value="page 2">

<script> function sendform(action) { document.getelementbyid('myform').action = action; document.getelementbyid('myform').submit(); } </script>

i did testing, alter method "get" , work, when alter method "post" , not able send anything.

i tried

print_r($_get); print_r($_post);

get able retrieve send value on select alternative tag. same code, post doesn't send through

i tried post

if action="" , work fine if action="http://www.myowndomain.com/subpage/page/thepage.php" not work post.

instead of javascript, utilize formaction attribute:

<input type="submit" formaction="<?php echo $domainurl;?>page_1" class="btn btn-primary btn-sm" value="page 1"> <input type="submit" formaction="<?php echo $domainurl;?>page_2" class="btn btn-primary btn-sm" value="page 2">

there's no need form="myform" when submit button within <form> element.

javascript php jquery html

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -