I'm using Javascript to send variables through a websites url and am trying to prevent the variables being copied over and over when a user keeps changing the same field:
ie Admin.php?pid=2&ENT=New_Web_Site_Launched&ENA=Stuart&ENA=Stuart&ENA=Stuart
I have multiple fields and have managed to get the first part working by removing the first "&" and everything after it out of the url by using the following piece of code.
function reload(form)
{
var val=form.NewsTitle.options[form.NewsTitle.options.selectedIndex].value;
url = location.href;
url = url.replace(/&.*$/,"");
self.location= url + '&ENT=' + val;
}
But I am having trouble removing everything from the second "&" and everything after it as I can't figure out the regex for it.
function reload2(form)
{
var
val2=form.NewsAuthor.options[form.NewsAuthor.options.selectedIndex].value;
url = location.href;
url = url.replace(Regex Here);
self.location= url + '&ENA=' + val2;
}
If somebody could help me I need a regex that will grab everything after and including the second "&" and everything after it as follows:
ie Admin.php?pid=2&ENT=New_Web_Site_Launched&ENA=Stuart&ENA=Stuart&ENA=Stuart
thanks Callum