Hey guys,
how do i write a function in javascript that can get the current url eg:
http://www.blahblah.com/apps/category.php?pg=1&catId=3021
and depending on a user selection choice, appends another parameter to the url like:
http://localhost/buyamonline/apps/category.php?pg=1&catId=3021&limit=5
but heres the catch:
Everytime the user selects a diff choice, I dont want to keep appending stuff like
http://localhost/buyamonline/apps/category.php?pg=1&catId=3021&limit=5&limit=10 and so on.
I want to always replace add it if there is no limit parameter or replace the value if there is one.
I was trying to accomplish this using sprintf but failed.
i was doing like so:
var w = document.mylimit.limiter.selectedIndex;
var url_add = document.mylimit.limiter.options[w].value;
var loc = window.location.href;
window.location.href = sprintf(loc+"%s="+%s, "&limit", url_add);