SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Nov 17, 2002, 04:37 #1
Query String parsing script is buggered
it doesn't show what ?n is equal to at the end document.write()
Code:<script> var newqstring = this.location.href.substring(this.location.href.indexOf('?')+1).split(";"); var _MOUS = new Array(); for(var q=0;q<newqstring.length;q++) { if(newqstring[q] != "") { var dynamic = newqstring[q].split("="); var _MOUS[dynamic[0]] = dynamic[1]; } } document.write(_MOUS['n']); </script>
I am DaMouse
Nobody can beat me so long as I'm stubborn -DaMouse
Squeak
-
Nov 18, 2002, 14:49 #2
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I wrote a function for that. Here it is, plus a sample use for you...
Code:<script> function parseGetVars() { var getVars = new Array(); var qString = top.location.search.substring(1); var pairs = qString.split(/\&/); for (var i in pairs) { var nameVal = pairs[i].split(/\=/); getVars[unescape(nameVal[0])] = unescape(nameVal[1]); } return getVars; } var _MOUS = parseGetVars(); </script> <script> document.write(_MOUS['n']); </script>
-
Dec 13, 2002, 02:50 #3
How about a different approach?
Hi,
It looks like you need a really simply solution for parsing the query string. I wrote a small script that does all the work for you. Check it out:
http://members.evolt.org/jeff/code/j...bles/index.cfm
Enjoy,
Jeff (.jeff)
Bookmarks