javascript - how to have 2 destination in 1 form using button and get the POST -
- i have 2 buttons in 1 form
- in 1st button can pass values page using
request
- but in 2nd button want again pass values page using
request
- the problem when click second button destination on destination of 1st button
- i have read answers, need change action using
javascript
i've tried suggestion doesn't work me.
<form action="first_btn_destination.php"> $data = "data1"; <input type="submit" name="first_btn" id="first_btn"> <input type="submit" name="second_btn" id="second_btn"> </form>
how can change action using javascript , pass value.
it not possible such thing without javascript. 1 way change action
attribute of form using javascript when click on form , submit manually.
take @ here see how can prevent form submitting on button clicking.
update:
the following code shows how change action
using javascript before submitting.
<form id="myform"> <input type="submit" name="first_btn" id="first_btn" onclick="modifyaction('http://google.com')"> <input type="submit" name="second_btn" id="second_btn" onclick="modifyaction('http://yahoo.com')"> </form> <script> var modifyaction = function(action) { document.getelementbyid('myform').action = action; }; </script>
Comments
Post a Comment