javascript - How to get value from and use -
javascript - How to get value from <option> and use -
this question has reply here:
using href links within <option> tag 6 answersnow have next code:
<form class="demo"> <select> <option selected>selecione sua cidade</option> <option value='jp'>joão pessoa - pb</option> <option value='outros'>outros</option> </select> </form>
what need:
when visitor click on dropdown menu , select alternative , go http://www.example.com each alternative go different adress.
value='jp' goes example.com
value='outros' goes example2.com
thanks!
edit: i'm using
<script> $('.demo select').change(function(){ window.location.href="http://www.example.com"; }); </script> </head>
but still not working, , how utilize open different links:
select alternative 1 = www.example1.com
select alternative 2 = www.example2.com
have urls values in select, , phone call function onchange:
<form class="demo"> <select onchange="go(this.value);"> <option selected>selecione sua cidade</option> <option value='http://someurl.com'>joão pessoa - pb</option> <option value='http://another.com'>outros</option> </select> </form> <script> function go(url){ window.location.href=url; } </script>
javascript jquery html
Comments
Post a Comment