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
Post a Comment