문제

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..

도움이 되었습니까?

해결책

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);

다른 팁

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

window.location.href += "?valor="+$('#landing-select').val().delay(100000).onload;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top