Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15869
| From | Tuxedo <tuxedo@mailinator.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Simple array reference question |
| Date | 2012-09-12 13:08 +0200 |
| Organization | albasani.net |
| Message-ID | <k2pqfc$uus$1@news.albasani.net> (permalink) |
| References | <k2pn0l$n7v$1@news.albasani.net> <50506600$0$21231$ba4acef3@reader.news.orange.fr> |
SAM wrote:
> Le 12/09/12 12:09, Tuxedo a écrit :
> > I have two simply arrays, for example:
> >
> > var birds = new Array('fowl', 'penguin', 'sparrow');
> > var fish = new Array('crayfish', 'jellyfish')
> >
> > When accessing a page including a parameter, such as 'page.html?fish'
> > and placing the string in a 'param' variable, how can the fish array be
> > returned?
> >
> > var param = location.search.substring(1);
> >
> > alert(param) ;
> >
> > Accessed as page.html?fish the above would of course fire up the alert
> > 'fish' and not the actual array named fish.
>
> alert(eval(param));
>
> alert('array = ' + param +
> '\nelement 1 = ' + eval(param)[1]
> );
>
Many thanks for the eval tricks!
Tuxedo
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simple array reference question Tuxedo <tuxedo@mailinator.com> - 2012-09-12 12:09 +0200
Re: Simple array reference question SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-09-12 12:37 +0200
Re: Simple array reference question Tuxedo <tuxedo@mailinator.com> - 2012-09-12 13:08 +0200
Re: Simple array reference question Stefan Weiss <krewecherl@gmail.com> - 2012-09-12 16:03 +0200
Re: Simple array reference question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-12 16:42 +0200
Re: Simple array reference question marat.rheingold@gmail.com - 2012-09-12 05:34 -0700
Re: Simple array reference question Tuxedo <tuxedo@mailinator.com> - 2012-09-12 15:10 +0200
Re: Simple array reference question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-12 15:36 +0200
Re: Simple array reference question Tuxedo <tuxedo@mailinator.com> - 2012-09-12 20:59 +0200
csiph-web