Thanks again... The nearest I can get is
for (J=0;J<Next.length;++J){ F["B"+Next[J]].disabled = "" DoSpecificTask[State](F) } which gives the first 3 answers but then the last one is undefined ...? I am not at all clear what I am iterating through?! Presumably through Next? One value of Next is 1,2 and presumably that means that B1 and B2 should be enabled? They are in fact. So why does this not work for the 4th answer, for B10 and B11? Any light on this?! Cheers Geoff On Apr 19, 12:20 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > Geoff, > > > but not sure how this works with the 2 dimensional array... > > The array you're looping through with for..in isn't two-dimensional, > is it? You're assigning Next to the sub-array (for lack of a better > term) within Arry, which is just one-dimensional (in fact, typically > single-element, although there are four of them that have two > elements). > > > From the link you give I should use > > > for (var index = 0; index < myArray.length; ++index) > > { var item = myArray[index]; > > F["B"+Next[J]].disabled = ""; > > DoSpecificTask[State](F); > > > } > > > but not sure how this works with the 2 dimensional array... > > > I've tried various permuations but .... > > I'm guessing you weren't quoting actual code you'd tried? That code > uses 'index' rather than 'J' as your index, uses 'myArray' instead of > 'Next', and assigns 'item' but never uses it. > > Separately, it's worth pointing out that JavaScript doesn't have multi- > dimensional arrays. It has arrays (which are really maps), and the > value of an element can be an array, but that's very different than > multi-dimensional arrays as in C, C++, and such. > > Hope this helps, > -- > T.J. Crowder > tj / crowder software / com > > On Apr 19, 11:57 am, geoffcox <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > Thanks for you reply - I'm having problems getting the iteration to > > work. In fact not sure how to iterate in this case... > > > From the link you give I should use > > > for (var index = 0; index < myArray.length; ++index) > > { var item = myArray[index]; > > F["B"+Next[J]].disabled = ""; > > DoSpecificTask[State](F); > > > } > > > but not sure how this works with the 2 dimensional array... > > > I've tried various permuations but .... > > > Help! > > > Cheers > > > Geoff > > > On Apr 19, 10:53 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > > > > Geoff, > > > > My guess is it's the for..in that's doing you in. Check out the docs > > > on Array > > > (http://www.prototypejs.org/api/array) and Enumerable > > > (http://www.prototypejs.org/api/enumerable) > > > for details. For..in does not iterate the elements of an array; it > > > iterates the properties of an object. These seem like the same thing > > > in some JavaScript implementations (but not all), but that stops > > > happening when Prototype adds its syntactic sugar to Array. > > > > Separately: You are relying quite heavily on semicolon insertion, > > > which can tend to obscure odd bugs. It's best to always explicitly > > > use semicolons, never to rely on JavaScript to guess correctly where > > > they should go. There are good maintainability reasons for this, as > > > well as the pragmatic reason that you pretty much can't use minimisers > > > on your code if you don't put semicolons in. > > > > Hope this helps, > > > -- > > > T.J. Crowder > > > tj / crowder software / com > > > > On Apr 19, 8:49 am, geoffcox <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > > > Can anyone please see why as soon as add a link to prototype.js I get > > > > an error message > > > > > F["B" + Next[J]] has no properties > > > > > I have tried changing the variable names but still get the error > > > > message. > > > > > Help! Cheers Geoff > > > > > var Arry = [ > > > > /* State 0 : */ [1,2], > > > > /* State 1 : */ [3], > > > > /* State 2 : */ [3], > > > > /* State 3 : */ [4,5], > > > > /* State 4 : */ [6], > > > > /* State 5 : */ [6], > > > > /* State 6 : */ [7,8], > > > > /* State 7 : */ [9], > > > > /* State 8 : */ [9], > > > > /* State 9 : */ [10,11]] > > > > > var result =new Array(); > > > > var test_num=1; > > > > function A(f) {soundManager.play('mySound'+test_num ,'../assets/audio- > > > > group1/Track' + (+test_num + 22) + '.mp3'); } > > > > function B(f) { result[test_num] = "same"; test_num++;} > > > > function C(f) { result[test_num] = "different";test_num++; } > > > > > DoSpecificTask = [A, B, C, A, B, C, A, B, C, A, B, C] > > > > > function Fn(Arg) { > > > > var F = Arg.form, State, J, Next > > > > State = Arg.value > > > > for (J=0 ; J<12 ; J++) F["B"+J].disabled = "disabled" // clear all > > > > Next = Arry[State] > > > > for (J in Next) F["B"+Next[J]].disabled = "" // set some > > > > DoSpecificTask[State](F) > > > > > }- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---