javascript - Getting submit type to post its value -


i trying value of button sent along form post, have:

  <form id="form1" name="form1" method="post" action="getdata">        <h1>quick query</h1>         <div class="floating-placeholder">             <input id="origin" name="origin" type="text" placeholder="number" value="5"/>             <label for="origin"></label>         </div>         <div class="floating-placeholder">             <input id="destination" name="destination" type="text" placeholder="number" value="4"/>             <label for="destination"></label>         </div>          <label>             <input type="submit" name="submitdriving" id="submitdriving" value="driving"/>              <input type="submit" name="submittransit" id="submittransit" value="transit" />             <input type="submit" name="submitcycling" id="submitcycling" value="cycling" />         </label>     </form> 

the current post has

{ origin: '5',   destination: '4' } 

i trying away if submitdriving button clicked post made is:

{ origin: '5',   destination: '4',   submitdriving: 'driving' } 

how can this?

the users expect more following select , single button submit form. keep simple approach.

<form id="form1" name="form1" method="post" action="getdata">        <h1>quick query</h1>         <div class="floating-placeholder">             <input id="origin" name="origin" type="text" placeholder="number" value="5"/>             <label for="origin"></label>         </div>         <div class="floating-placeholder">             <input id="destination" name="destination" type="text" placeholder="number" value="4"/>             <label for="destination"></label>         </div>         <div>             <select name="transittype" id="transittype">               <option>drive</option>               <option>cycling</option>               <option>transit</option>             </select>         </div>         <label>             <input type="submit" />          </label>     </form> 

you can accomplish original question javascript , listening onsubmit event of form. breaks standard ui users expect see.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -