logic and disabling onclicks?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    #16
    Re: logic and disabling onclicks?

    On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
    <jrs@merlyn.dem on.co.ukwrote:
    >The purpose of my posting that code was not to provide a Final Solution,
    >but to show how the routing structure could be compactly represented.
    John,

    Not sure whether you have seen my recent post but just one last point!

    Re the conflict with prototype.js - the problem I am told is probably
    the use of for/in to iterate over the Next values. It certainly seems
    to be so as when I try using the "vanilla" type of iteration I can add
    the link to prototype.js and do not get the associated error message.

    But! I have tried

    for (J=0;J<Next.len gth;++J){
    F["B"+Next[J]].disabled = false;
    DoSpecificTask[State](F);
    }

    This is not correct and comes up with "Next has no properties" on
    answering the 4th question.

    What would be the correct "vanilla" type iteration to replace your
    following code?

    for (J in Next) F["B"+Next[J]].disabled = false
    DoSpecificTask[State](F)

    Cheers

    Geoff


    Comment

    • Geoff Cox

      #17
      Re: logic and disabling onclicks?

      On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
      <jrs@merlyn.dem on.co.ukwrote:

      My great sainted ..........

      I should have written

      for (J=0;J<Next.len gth;++J){
      F["B"+Next[J]].disabled = false;
      }
      DoSpecificTask[State](F);

      This is not correct and comes up with "Next has no properties" on
      answering the 4th question.

      What would be the correct "vanilla" type iteration to replace your
      following code?

      for (J in Next) F["B"+Next[J]].disabled = false
      DoSpecificTask[State](F)

      Cheers

      Geoff

      Comment

      • Geoff Cox

        #18
        Re: logic and disabling onclicks?

        On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
        <jrs@merlyn.dem on.co.ukwrote:

        John

        the code below avoids the error "Next has no properties" by adding an
        extra item to Arry. But what I need is a way to stop the cycle rather
        than start it all over again...cannot yet see how to do this?

        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],
        /* State 10 : */ [0]] // extra item added


        var result =new Array();
        var test_num=1;
        function A(f)
        {
        soundManager.pl ay('mySound'+te st_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++;
        }

        function D(f) {
        alert('finished ');
        }

        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.name.substr ing(1,3);
        for (J=0 ; J<12 ; J++) F["B"+J].disabled = true; // clear all
        Next = Arry[State];

        //for (J in Next) F["B"+Next[J]].disabled = false;
        //DoSpecificTask[State](F);

        for (var J = 0; J < Next.length; ++J) {
        var item = Next[J];
        F["B"+item].disabled = false;
        }
        DoSpecificTask[State](F);

        }

        function getResults() {
        for (var i=1;i<5;i++) {
        alert(result[i]);
        }
        }

        </script>

        Comment

        • Geoff Cox

          #19
          Re: logic and disabling onclicks?

          On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
          <jrs@merlyn.dem on.co.ukwrote:

          John,

          You will be pleased to hear that all is well at last!

          I have used the vanilla iteration and prototype.js is OK. My solution
          is not very elegant I expect but it works ...

          Many thanks for your 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],
          /* State 10 : */ [12],
          /* State 11 : */ [12] ]

          var result =new Array();
          var test_num=1;
          function A(f)
          {
          soundManager.pl ay('mySound'+te st_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++;
          }

          function D(f) {
          alert('finished ');
          }

          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.name.substr ing(1,3);
          for (J=0 ; J<12 ; J++) F["B"+J].disabled = true; // clear all
          Next = Arry[State];

          for (var J = 0; J < Next.length; ++J) {
          F["B"+Next[J]].disabled = false;
          }
          if ( (State == 10) || (State == 11) ) {
          DoSpecificTask[State](F);
          sendGroup1Lab5( );
          } else {
          //alert(State);
          DoSpecificTask[State](F);
          }

          }

          Comment

          • Dr J R Stockton

            #20
            Re: logic and disabling onclicks?

            In comp.lang.javas cript message <bmnk04t860fbm2 aedho60e43qrnfc o2ic7@4ax.
            com>, Sat, 19 Apr 2008 22:09:45, Geoff Cox <gcox@freeuk.no tcomposted:
            >On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
            ><jrs@merlyn.de mon.co.ukwrote:
            >
            >My great sainted ..........
            >
            >I should have written
            >
            for (J=0;J<Next.len gth;++J){
            F["B"+Next[J]].disabled = false;
            }
            DoSpecificTask[State](F);
            >
            >This is not correct and comes up with "Next has no properties" on
            >answering the 4th question.
            >
            >What would be the correct "vanilla" type iteration to replace your
            >following code?
            >
            >for (J in Next) F["B"+Next[J]].disabled = false
            >DoSpecificTa sk[State](F)
            You said, I think, that you have no such problem until you use
            prototype.js; therefore, you should ask someone who knows that
            prototype.js.

            A Wikipedia search for prototype.js offers an amusing diversity of
            articles.

            --
            (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
            Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
            Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
            Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)

            Comment

            • Geoff Cox

              #21
              Re: logic and disabling onclicks?

              On Sun, 20 Apr 2008 18:10:34 +0100, Dr J R Stockton
              <jrs@merlyn.dem on.co.ukwrote:
              >In comp.lang.javas cript message <bmnk04t860fbm2 aedho60e43qrnfc o2ic7@4ax.
              >com>, Sat, 19 Apr 2008 22:09:45, Geoff Cox <gcox@freeuk.no tcomposted:
              >>On Sat, 19 Apr 2008 14:35:51 +0100, Dr J R Stockton
              >><jrs@merlyn.d emon.co.ukwrote :
              >>
              >>My great sainted ..........
              >>
              >>I should have written
              >>
              > for (J=0;J<Next.len gth;++J){
              > F["B"+Next[J]].disabled = false;
              > }
              > DoSpecificTask[State](F);
              >>
              >>This is not correct and comes up with "Next has no properties" on
              >>answering the 4th question.
              >>
              >>What would be the correct "vanilla" type iteration to replace your
              >>following code?
              >>
              >>for (J in Next) F["B"+Next[J]].disabled = false
              >>DoSpecificTas k[State](F)
              >
              >You said, I think, that you have no such problem until you use
              >prototype.js ; therefore, you should ask someone who knows that
              >prototype.js .
              >
              >A Wikipedia search for prototype.js offers an amusing diversity of
              >articles.
              John,

              You haven't seen my previous posting yet as all is now well!

              The problem re prototype was solved by replacing the for/in by the
              ordinary iteration.

              In fact someone on the Yahoo Ruby on Rails/Prototype/Scriptaculous
              group pointed out that the for/in caused the conflict.

              Cheers

              Geoff

              Comment

              Working...