javascript - how change the link form action a accordance with the `<option>`? -


this form search form. when click <option> "alfamart" or "bca", want link change. this, link: /en2/maps(alfamart)or(bca)/ in accordance <option>
how?

thanks

<form action="/en2/maps".$id."/"><!--relative url page map on-->        distination:       <select name="textsearchterms" class="selectpicker" data-live-search="true">          <option value="alfamart">alfamart</option>  	    <option value="bca">bca</option>      </select>       <input type="submit" value="search">  </form>    <?php  $id = $_get['textsearchterms'];  ?>

you don't need value url, can change form action select box value.

$('.selectpicker').change(function(){  if($(this).val() == 'alfamart'){  	$('form').attr('action','alfamart.html');    alert('action alfamart.html');  } else {  	$('form').attr('action','bca.html');    alert('action bca.html');  }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <form action="/en2/maps">        distination:       <select name="textsearchterms" class="selectpicker" data-live-search="true">          <option value="alfamart">alfamart</option>  	      <option value="bca">bca</option>      </select>       <input type="submit" value="search">  </form>


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -