I've already posted this at vb.org, but I'm not getting any response. Maybe someone here will have the answer?
I modified the function to change styles. It changes the styleid ok, but it also appends some gibberish to the querystring, such as:
index.php?styleid=10&styleid.x=11&styleid.y=19
Any idea where I went wrong?
Color indicates my changes
I modified the function to change styles. It changes the styleid ok, but it also appends some gibberish to the querystring, such as:
index.php?styleid=10&styleid.x=11&styleid.y=19
Any idea where I went wrong?
Code:
<form> <input name="styleid" type=image value="10" src="images/10.gif" onClick='switch_styleid(this);'> </form>
Code:
function switch_styleid(objinput)
{
styleid = objinput.value;
if (styleid == "")
{
return;
}
url = new String(window.location);
fragment = new String("");
// get rid of fragment
url = url.split("#");
// deal with the fragment first
if (url[1])
{
fragment = "#" + url[1];
}
// deal with the main url
url = url[0];
// remove styleid=x& from main bit
if (url.indexOf("styleid=") != -1 && is_regexp)
{
re = new RegExp("styleid=\\d+&?");
url = url.replace(re, "");
}
// add the ? to the url if needed
if (url.indexOf("?") == -1)
{
url += "?";
}
else
{
// make sure that we have a valid character to join our styleid bit
lastchar = url.substr(url.length - 1);
if (lastchar != "&" && lastchar != "?")
{
url += "&";
}
}
window.location = url + "styleid=" + styleid + fragment;
}