Re: String.protoype.toQueryParams

Alan Gutierrez
Fri, 28 Oct 2005 21:08:54 -0000

* Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org>
[2005-10-27 02:46]:
> Hi, I am trying to play with all the methods in the Array Object.
>
> Just wanted to check with you guys if this is the correct explanation of
toQueryParams().
> If yes, then I''ll add it to the documentation as well.
>
> Works for me (but I am not sure if it''s the correct way to use
it).
>
>   /* String.prototype.toQueryParams takes a query string, i.e, string with
>      name value pairs separated with ''&'', splits them
up and returns an object
>      using whose properties we can get the values of the params */
>   /* Usage:
> 		var queryString =
"?name=mandy&email=mandiv-/E1597aS9LQAvxtiuMwx3w@public.gmane.org&age=20";
> 		name = queryString.toQueryParams().name;
> 		email= queryString.toQueryParams().email;
> 		age  = queryString.toQueryParams().age;
> 		alert(name+" "+email+" "+age);
>   */

    Since the query string is calcluated, I think a better usage
    would be:

    var str =
"?name=mandy&email=mandiv-/E1597aS9LQAvxtiuMwx3w@public.gmane.org&age=20"
    var qs = str.toQuerySTring();
    alert(qs.name + " " + qs.email + " " + qs.ag);

--
Alan Gutierrez - alan-JbsJTiZCByIAvxtiuMwx3w@public.gmane.org -