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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -