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 answers

now 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

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -