[thelist] Javascript Brain *fluff

.jeff jeff at members.evolt.org
Thu Feb 20 21:34:06 CST 2003


ben,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Ben Henick
>
> a = window.location.search.substring(1);
> b = a.split("&");
>
> /* Unless you have an obscene (more than, say, six or
>    eight) quantity of name-value pairs on that URL,
>    there's probably little harm in: */
>
> for (i = 0; i < b.length; i++)
> {
>   eval(b[i]);
> }
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

sure, but do you want variables from the query string bombarding the global
scope of variables?  seems like a recipe for disaster if you're not *really*
careful about naming.  since you can't control what the user might do with
the url, i'd say you're better off with the variables from the url going
into some sort of object as keys.  hence the development of the url object:

http://members.evolt.org/jeff/code/js_url_variables/index.cfm

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> c = new Array();
> d = new String();
> e = new Array();
>
> for (i = 0; i < b.length; i++)
> {
>   c = b[i].split("=");
>   d = c[0];
>   e[d] = c[1];
> }
>
> /*  Which creates an associative array to the effect of
> CGIArray["varname"] = foo; */
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

how do you get CGIArray[] from e = new Array(); ??

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list