javascript - how to keep the same form after window.location.replace -


i have form select drop down menu calls on javascript function reloads page parameters query string. want have same dropdown option selected when page replaced. how should go doing this?

select form:

<select name="fill_position" id="fill_position" onchange="reloadshowform()">

js:

function reloadshowform() {      var fill_pos = $('#fill_position').val();     window.location.replace(window.location.href + "&fill_position=" + fill_pos); } 

you have parse parameters @ first.

here function radicand provided in post:

function geturlparameter(name) {     return decodeuricomponent((new regexp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; } 

add code , use snippet:

var fillposition = geturlparameter("fill_position"); if (fillposition !== null) {   $("#fill_position").val( geturlparameter("fill_position") ); } 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -