I have a URL which looks something like this ...
http://xx.xx.xxx.xx/olgc/contacts.asp?action=&opt=&orderby=Promo&page=3
and, what I'd like to do, is be able to replace the orderby=Promo with various things, such as last_name/etc, and re-load the page. Currently, what I have is at the top of the table, is headers with things like <a href="Javascript:reorder('Last_Name');>
and the functions..
code:
function getOrder(pair)
{
var temp = pair.split("=")
return temp[0];
}
function changeorder(neworder)
{
var httpArray = window.location.toString().split('&');
for(x=0;x<httpArray.length;x++) {
if(getOrder(httpArray[x]) == 'orderby')
httpArray[x] = "orderby=" + neworder;
}
window.location.replace(httpArray.join("&"));
}
This works, however.. I have a nagging feeling this isnt the best way of going about it. I have re-written it once (first version managed to be 2x as long for some reason...), but still think it 'could be better'. Not sure why I'm so focused on a trivial little piece of code, I guess its just me not wanting to read 60 pages of stats homework