Search code examples
yui3

Loading a URL when dropdown option Changes in YUI


I am trying to load a URL when a drop down menu changes via YUI Change event. I just want to navigate to that URL.

I made a long search. But didn't got any way.

Thanks :)


Solution

  • <select id="dropdown">
        <option value="http://example.com/home">Home</option>
        <option value="http://example.com/about">Abount</option>
    </select>
    
    
    Y.one("#dropdown").on("change", function() {
        //'this' points to dropdown node
        //so it's value is a value of selected option. Assume you keep new url there
        document.location.href = this.get('value'); 
    });