Question

I have a select drop down and each option has a value of something like "?add-to-cart=31". I need a way so that when an option is clicked that it will assign the selected options value to the page url and reload the page (with the new parameter).

I have this:

jQuery("#landing-select option").click(function(){
addtocart();
})
function addtocart()
{
    window.location.href + $('#landing-select').val.delay(100000).onload;
    //alert('HI');

}
};

Am I missing something? I would like it to add the options value to the browsers url and refresh the page. I added the delay in there so the parameter had time to set to the url before the page reloaded..

Was it helpful?

Solution

You are missing += and .val()

 window.location.href += $('#landing-select').val().delay(100000).onload;
 //                   ^^                         ^^

Also .delay() wont work for this, use setTimeout instead

setTimeout(function(){
     window.location.href += $('#landing-select').val()
},100000);

OTHER TIPS

You forgot the () on the .val method. Should be .val()

window.location.href += "?valor="+$('#landing-select').val().delay(100000).onload;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top