Jump to content

Custom select

Bryan Somto

Recommended Posts


The link above is a custom select dropdown. I'm trying to get each item in the dropdown go to a link. I've tried using;


Please select city : 

<select name="select-city" onchange="location = this.value;"> 

<option value="">Select-City</option> 

 <option value="https://en.wikipedia.org/wiki/New_Delhi">New Delhi</option> 

 <option value="https://en.wikipedia.org/wiki/New_York">New York</option> 

 <option value="https://en.wikipedia.org/wiki/Bern">Bern</option> 

 <option value="https://en.wikipedia.org/wiki/Beijing">Beijing</option> 



And this,

<select name="formal" onchange="javascript:handleSelect(this)"> 

<option value="home.com">Home</option> 

<option value="https://www.Facebook.com">Contact</option> 



<script type="text/javascript"> 

function handleSelect(elm) 

window.location = elm.value; 



Link to comment
Share on other sites

try this:

<select name="list" id="list" accesskey="target">
    <option value='none' selected>Choose a theme</option>
    <option value="https://en.wikipedia.org/wiki/New_Delhi">New Delhi</option>
    <option value="https://en.wikipedia.org/wiki/Gujarat">Gujarat</option>
    <option value="https://en.wikipedia.org/wiki/New_Delhi">New delhi</option>
<input type=button value="Go" onclick="goToNewPage()" />

and JS file:

 function goToNewPage()
        var url = document.getElementById('list').value;
        if(url != 'none') {
            window.location = url;


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...