I have a question regarding changing the URL that has some form information but might cause duplications. It’s kind of hard to explain in one sentence. So I have a form for searching and trying to do pagination using a drop down. The URL would be something like this:
http://www.site.com/page/?name=Amanda&state=WA&approved=-2&form_date=&submit=Submit
…and the code below adds the page call just fine (for example)
http://www.site.com/page/?name=Amanda&state=WA&approved=-2&form_date=&submit=Submit&page=2
However if they change the page again, it’s gonna duplicate the page call so it’ll be
http://www.site.com/page/?name=Amanda&state=WA&approved=-2&form_date=&submit=Submit&page=2&page=2
I know how to fix it via PHP, but I’d like to keep it in jQuery if possible. Below is my jQuery call. Would I have to do an indexOf call? Is that the only way? I thought there was another way so I thought I’d just ask.
$('#page').change(function(){
var pathName = window.location.search;
var page_change = $('#page option:selected').val();
if(pathName == ""){
window.location.replace("?page="+page_change);
} else {
window.location.replace(pathName+"&page="+page_change);
}
});
Thanks!!!
Is this what you meant?