input text lose value when window.location.href is called
Hi,
I have an input text and button search, when a user type a text a script redirect the page with the text as parameter, but after the redirect (in the same page) the input text lose the value, I tried to reload value from paramters with no luck
Help please ?
this is my code :
- <script type="text/javascript">
- function RedirectUrlSearch()
- {
- var tb = document.getElementById("tbSearch").value;
- if((tb != null))
- {
- window.location.href="?FilterName=SalesforceCaseNumber&FilterMultiValue=*"+tb+"*";
- if (window.location.href.search("SalesforceCaseNumber")!=-1){
- function getUrlVars()
- {
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++)
- {
- hash = hashes[i].split('=');
- vars.push(hash[0]);
- vars[hash[0]] = hash[1];
- }
- return vars;
- }
- var first = getUrlVars()["FilterMultiValue"];
document.getElementById('tbSearch').value = first;
- }
- }
- return false;
- }
- </script>
- <table>
- <tr>
- <td>SalesforceCaseNumber : <input name="T1" id="tbSearch" type="text"/></td>
- <td><input id="btnSearch" onclick="return RedirectUrlSearch();" type="button" value="search"/> </td>
- </tr>
- </table>