Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
101
rated 0 times [  106] [ 5]  / answers: 1 / hits: 98144  / 12 Years ago, tue, august 21, 2012, 12:00:00

Possible Duplicate:

Get query string values in JavaScript






how can i get the get variable in javascript?



i want to pass it in jquery function.



function updateTabs(){

//var number=$_GET['number']; how can i do this?
alert(number);
$( #tabs ).tabs({ selected: number });

}

More From » get

 Answers
74
var $_GET = {};
if(document.location.toString().indexOf('?') !== -1) {
var query = document.location
.toString()
// get the query string
.replace(/^.*??/, '')
// and remove any existing hash string (thanks, @vrijdenker)
.replace(/#.*$/, '')
.split('&');

for(var i=0, l=query.length; i<l; i++) {
var aux = decodeURIComponent(query[i]).split('=');
$_GET[aux[0]] = aux[1];
}
}
//get the 'index' query parameter
alert($_GET['index']);

[#83518] Sunday, August 19, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
minab

Total Points: 701
Total Questions: 104
Total Answers: 91

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;