Array Issue 3nd Part.

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

    #1

    Array Issue 3nd Part.

    Hi all,

    In this URL.




    If you view the source code, you'll see the original order (JavaScript
    Array):

    ID = ORDER

    Original Order:

    1 = 1
    4 = 2
    5 = 3
    7 = 4


    Try this, move the first image to the last one, when you clicks on
    "SubmiT" this order should be:

    1 = 4
    4 = 2
    5 = 3
    7 = 1

    But this show:

    1 = 2
    4 = 3
    5 = 4
    7 = 1

    So, any know what is the problem ?,

    Thanks in advanced.

    -- eft0.
  • eric

    #2
    Re: Array Issue 3nd Part.

    Hi,
    It works for me....do you clear the cache on your browser every once in
    a while.

    The only line I am not sure about is the:
    eval("document. frm1.id_" + Thumbnails[cnt][3] + ".value='" + Order2
    +"';");

    It seems like you are only updating one form element value per loop
    when it seems to me you should change two ---the one you are moving the
    the one that moves into it's place.

    But then again it seems to work for me other than the fact that the
    order shows
    5=>
    4=>
    1=>
    7=>
    on the server requests.
    ??

    Comment

    • RobB

      #3
      Re: Array Issue 3nd Part.

      eft0 wrote:[color=blue]
      > Hi all,
      >
      > In this URL.
      >
      > http://www.streetball.cl/JS/ChangeOrder.php?id=1
      >
      >
      > If you view the source code, you'll see the original order[/color]
      (JavaScript[color=blue]
      > Array):
      >
      > ID = ORDER
      >
      > Original Order:
      >
      > 1 = 1
      > 4 = 2
      > 5 = 3
      > 7 = 4
      >
      >
      > Try this, move the first image to the last one, when you clicks on
      > "SubmiT" this order should be:
      >
      > 1 = 4
      > 4 = 2
      > 5 = 3
      > 7 = 1
      >
      > But this show:
      >
      > 1 = 2
      > 4 = 3
      > 5 = 4
      > 7 = 1
      >
      > So, any know what is the problem ?,
      >
      > Thanks in advanced.
      >
      > -- eft0.[/color]

      Just as a side issue - lines of JavaScript like this:

      eval("alert('MO VE2: ' + document.frm1.i d_" + Thumbnails[new_cnt][3] +
      ".value);") ;

      ....are patently ridiculous. Instead of simply writing a line of actual
      code & running it, you're expressing it (painfully) as a string, then
      running it through eval() to 'de-string' it so it will actually run.
      It's as if you were scripting twice for every statement, once in
      'string-o-javascript' and then in 'genuine-jav-o-script'.

      alert('MOVE2: ' + document.frm1['id_' +
      Thumbnails[new_cnt][3]].value);

      And:

      document['img_' + cnt].src = Thumbnails[new_cnt][1];



      Comment

      • eric

        #4
        Re: Array Issue 3nd Part.

        "...are patently ridiculous."
        Ouch...sure it ain't pretty but it does do the job. Was tempted to
        point it out myself. Not likely to be the cause of the trouble, though
        ;-)

        Comment

        • Randy Webb

          #5
          Re: Array Issue 3nd Part.

          eric wrote:
          [color=blue]
          > "...are patently ridiculous."
          > Ouch...sure it ain't pretty but it does do the job.[/color]

          That depends on your definition of "does do the job". Its tantamount to
          using a sledgehammer to drive a finishing nail in a board. Sure, it
          "does the job" but its not the most efficient way to do it.
          [color=blue]
          > Was tempted to point it out myself.[/color]

          Nothing wrong with pointing out mistakes in code, especially when that
          code is being questioned.
          [color=blue]
          > Not likely to be the cause of the trouble, though[/color]

          Me either, but would you mind reading the Group FAQ?

          --
          Randy
          comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

          Comment

          • eft0

            #6
            Re: Array Issue 3nd Part. - SOLVED.

            Its Solved, thanks to all.

            Comment

            • Zifud

              #7
              Re: Array Issue 3nd Part.

              Randy Webb wrote:[color=blue]
              > eric wrote:
              >[color=green]
              >> "...are patently ridiculous."
              >> Ouch...sure it ain't pretty but it does do the job.[/color]
              >
              >
              > That depends on your definition of "does do the job". Its tantamount to
              > using a sledgehammer to drive a finishing nail in a board. Sure, it
              > "does the job" but its not the most efficient way to do it.[/color]

              I disagree. If the objective was to consume far more energy
              than required and provide an opportunity to demolish part or all
              of the building at the same time as driving the nail (presuming
              all goes well), then a sledgehammer makes perfect sense. >-)


              --
              Zif

              Comment

              Working...