Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
170
rated 0 times [  171] [ 1]  / answers: 1 / hits: 51075  / 14 Years ago, fri, september 24, 2010, 12:00:00

Possible Duplicate:

get querystring with jQuery






How do I get the value of a querystring into a textbox using jQuery?



Lets say the url is http://intranet/page1.php?q=hello



I would like the hello to be in the textbox.


More From » jquery

 Answers
29

In my programming archive I have this function:



function querystring(key) {
var re=new RegExp('(?:\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}


You can use that to get the query string value and put in a textbox:



$('#SomeTextbox').val(querystring('q'));

[#95507] Wednesday, September 22, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sabinal

Total Points: 144
Total Questions: 112
Total Answers: 107

Location: Ghana
Member since Mon, Aug 22, 2022
2 Years ago
;