how to get the one option from select tag in html using php -


 <form action='' method="post">          <select class="form-control" id='qty' name='qty'>                  <option value='1'>1</option>                  <option value='2'>2</option>                  <option value='3'>3</option>         </select>         <input type="submit" name="submit" value="add cart">     </form>      <?php     if (isset($_post['submit']))      {     $qty = $_post['qty'];      echo "$qty";     }      ?> 

i trying to fetch 1 of option select tag.but don't know how fetch post method using form. have display the data got through form. please correct me if did mistake in coding php

you have submit form either using button or submit form on change of qty.

onchange="this.form.submit()"

<form action='' method="post">     <select class="form-control" id='qty' name='qty' onchange="this.form.submit()">          <option value='1'>1</option>          <option value='2'>2</option>          <option value='3'>3</option>     </select> </form>  <?php     if (isset($_post['qty'])){         $qty = $_post['qty'];         echo $qty;     }  ?> 

if javascript disabled above code not work in case had use submit button

<form action='' method="post">     <select class="form-control" id='qty' name='qty'>          <option value='1'>1</option>          <option value='2'>2</option>          <option value='3'>3</option>     </select>     <input type="submit" name="submit" value="submit"> </form>  <?php     if (isset($_post['qty'])){         $qty = $_post['qty'];         echo $qty;     }  ?> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -