Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. how to paas a asp array to javascript's function ???

how to paas a asp array to javascript's function ???

Scheduled Pinned Locked Moved Web Development
javascriptclouddata-structureshelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ankur Bakliwal
    wrote on last edited by
    #1

    hello all, I want to paas a asp array to javascript's function. is this possible i m no able to paas this array to that function. i m doing like this way - <% myArray = rs.getrows %> function myFun(arrVal) { .... } pls help me Thanks, Ankur Bakliwal

    D 1 Reply Last reply
    0
    • A Ankur Bakliwal

      hello all, I want to paas a asp array to javascript's function. is this possible i m no able to paas this array to that function. i m doing like this way - <% myArray = rs.getrows %> function myFun(arrVal) { .... } pls help me Thanks, Ankur Bakliwal

      D Offline
      D Offline
      Dmitry Khudorozhkov
      wrote on last edited by
      #2

      You seem to misunderstand how ASP and Javascript work. ASP works server-side; by the time the user receives his/her HTML+Javascript, ASP objects (and arrays, which are objects also) do not exist any more. That is why your code doesn't work. To fix it(easy way): construct a string with ASP script, that will contain all members of the array, delimited my comma; pass this string to the Javascript (like you did) and construct an array within Javascript back.

      ------------------------- Listen up! Teamwork means staying out of my way! (Seifer, Final Fantasy 8).

      A 1 Reply Last reply
      0
      • D Dmitry Khudorozhkov

        You seem to misunderstand how ASP and Javascript work. ASP works server-side; by the time the user receives his/her HTML+Javascript, ASP objects (and arrays, which are objects also) do not exist any more. That is why your code doesn't work. To fix it(easy way): construct a string with ASP script, that will contain all members of the array, delimited my comma; pass this string to the Javascript (like you did) and construct an array within Javascript back.

        ------------------------- Listen up! Teamwork means staying out of my way! (Seifer, Final Fantasy 8).

        A Offline
        A Offline
        Ankur Bakliwal
        wrote on last edited by
        #3

        Thanks for this information. but i have 2d array like this abc 23 44 pqr 22 444 qwe 20 4444 zxc 21 44 How is this possible to pass a string ?????

        Thanks, Ankur Bakliwal

        G 1 Reply Last reply
        0
        • A Ankur Bakliwal

          Thanks for this information. but i have 2d array like this abc 23 44 pqr 22 444 qwe 20 4444 zxc 21 44 How is this possible to pass a string ?????

          Thanks, Ankur Bakliwal

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          There are no two dimentional arrays in Javascript, so you have to use a jagged array. Loop through your array and construct a string with Javascript code from it that looks like this: var MyArray = [['abc','23','44'],['pqr','22','444'],['qwe','20','4444'],['zxc','21','44']];

          --- single minded; short sighted; long gone;

          A 1 Reply Last reply
          0
          • G Guffa

            There are no two dimentional arrays in Javascript, so you have to use a jagged array. Loop through your array and construct a string with Javascript code from it that looks like this: var MyArray = [['abc','23','44'],['pqr','22','444'],['qwe','20','4444'],['zxc','21','44']];

            --- single minded; short sighted; long gone;

            A Offline
            A Offline
            Ankur Bakliwal
            wrote on last edited by
            #5

            Thanks

            Thanks, Ankur Bakliwal

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups