I'm trying to create or append new queries to the URL without refresh.
Current solution
PHP
echo'<a href="" onclick="addOrUpdateUrlParam(\'doorid\', ' . $row["door_style_id"] . '); return false;">';
JS
function addOrUpdateUrlParam(name, value)
{
var href = window.location.href;
var regex = new RegExp("[&\\?]" + name + "=");
if(regex.test(href))
{
regex = new RegExp("([&\\?])" + name + "=\\d+");
window.location.href = href.replace(regex, "$1" + name + "=" + value);
}
else
{
if(href.indexOf("?") > -1)
window.location.href = href + "&" + name + "=" + value;
else
window.location.href = href + "?" + name + "=" + value;
}
}
This works perfectly for appending or creating new queries as intended. But refreshes the page on click.
Any help appreciated, thanks.