On Oct 28, 8:37 pm, jack7890 <[EMAIL PROTECTED]> wrote:
> I'm trying to use a for loop to initialize a large number of
> script.aculo.us sliders.  I'm finding that, for some reason, I'm
> unable to store control.slider objects in an array.  For example,
> consider this code:
>
> [code]
> var contextRaters_primary = new Array();
>
> for(var i = 0; i < 1; i++) {
>
> var contextRaters_primary[i] = new Control.Slider($
> ('contextRaterHandle_primary1'),$('contextRaterTrack_primary1'),
>                 {
>                 axis:'vertical'
>                 });}
>
> [/code]
>
> I know that this for loop will only iterate once, but I'm using it to
> show my point.  If I delete the "[i]" from the end of
> "contextRaters_primary[i]" then it runs fine.  But when I try to run
> it as I've written it, I get a "missing ; before statement" error.  So
> for some reason it doesn't work when I try to store the slider as a
> variable in an array.
>
> Could someone PLEASE tell me why this might be?  I feel like the
> answer is relatively obvious, but I'm relatively new to this and can't
> figure it out.

`[` and `]` can not be part of Identifier. In other words, by
prepending `var` you try to declare a variable and that variable's
name is syntactically wrong : )

Just omit `var`:
...
contextRaters_primary[i] = ...
...

>
> Thanks.

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to