5 Replies Latest reply on Jun 23, 2006 7:14 AM by kglad

    LoadVarsdoes not read array from ASP

    luciewong Level 1
      Hi,
      my ASP writes out this variables:
      i1_seatno0=EXZ8420&i1_seatno1=FYA9531&i1_seatno2=ZB0642&i1_seatno3=HAB5188&i1_seatno4=IBC6 299&

      now I want these vars pushed into an Array and added to my Tno_list.
      I have a button, which onPress sends me to Frame 4.
      On Frame 4
      I have this code:



      //load new pass no in
      var send_lvConfirm:LoadVars = new LoadVars();
      var result_lvConfirm:LoadVars = new LoadVars();

      result_lvConfirm.onLoad = function(success) {
      if (success) {
      if (result_lvConfirm.getBytesLoaded() == result_lvConfirm.getBytesTotal() && result_lvConfirm.getBytesTotal()>0) {
      for(var c:Number = 0;c<5;c++){
      _parent.myno_array.push(result_lvConfirm["i1_seatno"+c]);
      Tno_list.addItem({label:result_lvConfirm["i1_seatno"+c]});
      }
      //end for
      }
      //end bytes
      }
      //end success
      }
      end load
      send_lvConfirm.sendAndLoad("loadSeatno.asp",result_lvConfirm,"POST");



      It always adds only o n e - the first item to the Array, as well as to the list - only the first item.
      The other 4 items( in the Array and in the List) are always "undefined" .

      What I am doing wrong?
      Please help

      best regards
      Luciewong
        • 1. Re: LoadVarsdoes not read array from ASP
          kglad Adobe Community Professional & MVP
          show your php code or double check to see if all those variable/values are returned.
          • 2. Re: LoadVarsdoes not read array from ASP
            luciewong Level 1
            Hi kglad,
            below is my ASP code and it writes out the vars like I want it.
            I add to each var a record number, in this example 0 to 4, because my request to the asp is 5 ( I want 5 records returned)
            Asp Output is:
            i1_seatno0=SUMEXZ8420&i1_seatno1=SUMFYA9531&i1_seatno2=SUMGZB0642&i1_seatno3=SUMHAB5188&i1 _seatno4=SUMIBC6299&



            Asp code is:
            set rs = Server.CreateObject("ADODB.recordset")
            rs.open "seatno10000", con, 2,2

            myno = 0
            'noTotal = request.QueryString >> must be converted to number<<<<<("'" & noTotal & "'") '&"&"
            myTotal = CInt(intPage)'request.QueryString(("noTotal")) '&"&"


            If Not rs.BOF Then
            rs.movefirst
            Do while myno < myTotal 'intPage

            Response.write "i1_seatno" & myno & "=" &(rs("i1_seatno"))& "&"

            rs.movenext
            myno = myno + 1
            Loop

            end If
            rs.close

            <<this works ok, when I call the ASP in the Browser, it writes out all ok, but the LV receives or writes only the first 1 value [EXZ8420] and it writes the other 4 as 'undefined'.
            It also adds to my List only the first value,,,,,, the other 4 below are 'undefined'.
            Hmm, since 2 days I am on this now....
            Hope, you can help.

            Best regards
            Luciewong
            • 3. Re: LoadVarsdoes not read array from ASP
              kglad Adobe Community Professional & MVP
              that asp code isn't going to work with flash. when indicating concatenation within your php, use the period instead of the ampersand:

              Response.write "i1_seatno".myno."=".(rs("i1_seatno"))."&";
              • 4. Re: LoadVarsdoes not read array from ASP
                luciewong Level 1
                Hi kglad,
                Thank you for your Help, I just want to inform you what the problem was.
                In my ASP I had the following code above all:

                If Request("noTotal") = "" Then
                intPage = 1
                Else
                intPage = Request("noTotal")
                End If

                So... after 3 days I found out, that he could'nt just read my request coming from Flash.
                So If my request is "nothing" he will write out always only 1 seat number.
                But when I tested the ASP in the Browser by writing " http://retrieve_seatno.asp?noTotal=5" he always write me out
                the correct 5 seat numbers.

                The problem was:
                sendlv_Confirm.noTotal = noTotal;<<where <noTotal> was a number/ASP request must be a String

                so I changed:
                sendlv_Confirm.noTotal = noTotal.toString(); <<this made it working/then my ASP could read the request

                I know, that you don't work with ASP usually, so I just want to tell you, that the following code is correct:

                Response.write "i1_seatno" & myno & "=" &(rs("i1_seatno"))& "&"
                If I replace the ampersand the ASP doesn't work anymore.

                - the ampersand adds 'myno' to the String "i1_seatno" and writes out <i1_seatno1=....>, so I could iterate through many records by calling their id number.

                Very much appreciate your help.
                Best regards
                Luciewong




                • 5. Re: LoadVarsdoes not read array from ASP
                  kglad Adobe Community Professional & MVP
                  you're welcome. i thought you were using php although in my message it looks like i was even confused about that.