[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
ClanKiller.com :: View topic - a handy javascript function for getting GET vars
ClanKiller.com
https://forums.clankiller.com/

a handy javascript function for getting GET vars
https://forums.clankiller.com/viewtopic.php?f=24&t=2167
Page 1 of 1

Author:  Satis [ Thu Jan 18, 2007 7:41 am ]
Post subject:  a handy javascript function for getting GET vars

hey, I found this online somewhere and thought I'd share. I make prolific use of GET vars where it makes sense (you can bookmark a GET, after all), and I make prolific use of javascript for AJAX, but getting a GET var with javascript can be a pain. This function does it for you.

[php]
function gup(name){
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var tmpURL = window.location.href;
var results = regex.exec( tmpURL );
if( results == null )
return "";
else
return results[1];
}
[/php]

just pass it the name of the var you want and it'll send back the value. VERY handy.

[php]
function whatever(){
document.getElementById('PigIsTheCoolest').innerHTML = gup('PigGetVar');
}
[/php]

Author:  Pig [ Thu Jan 18, 2007 12:12 pm ]
Post subject: 


Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/