Questo metodo è utile se vogliamo ad esempio inviare il valore in un'altra pagina html o php.
<html>
<body>
<form name='frmPagin' action='javascript:searchItem();' method='post'>
<table border="0" >
<tr>
<td valign="top">
<input name="inputsearch" id="inputsearch"
type="text" maxlength="80" placeholder="Search">
</td>
</tr>
<tr>
<td valign="top">
<input name="btnsearch" id="btnsearch" type="submit" value"SEND">
</td>
</tr>
</table>
<script>
function searchItem(){
addOrUpdateUrlParam('Search',document.getElementById("inputsearch").value);
}
function addOrUpdateUrlParam(name, value)
{
var href = window.location.href;
var regex = new RegExp("[&\\?]" + name + "=");
if(value=="")
value="0";
if(regex.test(href))
{
regex = new RegExp("([&\\?])" + name + "=\\w+");
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;
}
}
</script>
</form>
</body>
</html>