469,331 Members | 6,038 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Dynamic Variable ?

Hi all,

hopefully someone knows the answer to this one !

Im trying to use something like this...
>var riders = dropriders.split(",");

for (x in riders)
{
var shebang = strvalue.concat("rider" , riders[x]);
value += rPrice[document.myteam.shebang.value];
}
dropriders can be from one to ten elements looking something like --1,2,6

Therefore in the value += line, i would want shebang to be replaced by
rider1, rider2, rider6.

Any thoughts ?

Thanks in advance,

Leon
May 10 '07 #1
2 1254
On May 11, 8:10 am, Leon <l...@dontcallmeeeore.co.ukwrote:
Hi all,

hopefully someone knows the answer to this one !
The FAQ does...

Im trying to use something like this...
>var riders = dropriders.split(",");
>>
>for (x in riders)
>{
>var shebang = strvalue.concat("rider" , riders[x]);
>value += rPrice[document.myteam.shebang.value];
>}

dropriders can be from one to ten elements looking something like --1,2,6

Therefore in the value += line, i would want shebang to be replaced by
rider1, rider2, rider6.

Any thoughts ?
<URL: http://www.jibbering.com/faq/#FAQ4_39 >
--
Rob

May 10 '07 #2
In comp.lang.javascript message <4643986b$0$8711$ed2619ec@ptn-nntp-
reader02.plus.net>, Thu, 10 May 2007 23:10:51, Leon
<le**@dontcallmeeeore.co.ukposted:
>>var shebang = strvalue.concat("rider" , riders[x]);
value += rPrice[document.myteam.shebang.value];
>Therefore in the value += line, i would want shebang to be replaced by
rider1, rider2, rider6.
FAQ 4.25 provides the necessary clue. FAQ 4.39 is better. They should
be merged, or at least consecutive.

The example in 4.39, while valid, is pointless; there should also be an
example with a variable string, such as "Item"+N. I can see no point in
using bracket notation where the string is a constant known at code-
writing time.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by fivelitermustang | last post: by
1 post views Thread by Nathan Bloomfield | last post: by
2 posts views Thread by Martin Hart - Memory Soft, S.L. | last post: by
2 posts views Thread by deejayquai | last post: by
2 posts views Thread by Luis Arvayo | last post: by
14 posts views Thread by vivek | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.