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
  1. Home
  2. Web Development
  3. How to transfer an array of data (retrived from database at server side) to client side variables?

How to transfer an array of data (retrived from database at server side) to client side variables?

Scheduled Pinned Locked Moved Web Development
tutorialdatabasesysadmindata-structuresquestion
6 Posts 3 Posters 11 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.
  • M Offline
    M Offline
    mkashifkkj
    wrote on last edited by
    #1

    I have two list boxes. First list box is filled with some enteries from database. Now when user select one entry from first list box(client-side event) then second list box is filled with values based on that first selection. Second list box enteries are retrived from database(server side action). Guide me how to do this.

    J 1 Reply Last reply
    0
    • M mkashifkkj

      I have two list boxes. First list box is filled with some enteries from database. Now when user select one entry from first list box(client-side event) then second list box is filled with values based on that first selection. Second list box enteries are retrived from database(server side action). Guide me how to do this.

      J Offline
      J Offline
      Johan de Koning
      wrote on last edited by
      #2

      Simple solution is to use a postback in ASP.Net and then get the items for the other listbox Other solution is to create an asp.net page which generates XML. XML can be loaded by javascript at the client side. And then you can change the entries of the second box. A thing i have to warn you is that the Viewstate will not work because the items are not set runtime. But you can still use Page.Response["ddlName"] tot get the selected one. The last solution is very sexy i think. Maybe i will write my first article about this. :-D

      M 1 Reply Last reply
      0
      • J Johan de Koning

        Simple solution is to use a postback in ASP.Net and then get the items for the other listbox Other solution is to create an asp.net page which generates XML. XML can be loaded by javascript at the client side. And then you can change the entries of the second box. A thing i have to warn you is that the Viewstate will not work because the items are not set runtime. But you can still use Page.Response["ddlName"] tot get the selected one. The last solution is very sexy i think. Maybe i will write my first article about this. :-D

        M Offline
        M Offline
        mkashifkkj
        wrote on last edited by
        #3

        Thanks for ur reply. I want code for ASP 3.0 :-D

        S 1 Reply Last reply
        0
        • M mkashifkkj

          Thanks for ur reply. I want code for ASP 3.0 :-D

          S Offline
          S Offline
          Sarvesvara BVKS Dasa
          wrote on last edited by
          #4

          mkashifkkj wrote: I want code for ASP 3.0 I have the code of it... but its flavoured with Java Script too... interested?? I was born intelligent
          Education ruined me!.

          M 1 Reply Last reply
          0
          • S Sarvesvara BVKS Dasa

            mkashifkkj wrote: I want code for ASP 3.0 I have the code of it... but its flavoured with Java Script too... interested?? I was born intelligent
            Education ruined me!.

            M Offline
            M Offline
            mkashifkkj
            wrote on last edited by
            #5

            yes send it

            S 1 Reply Last reply
            0
            • M mkashifkkj

              yes send it

              S Offline
              S Offline
              Sarvesvara BVKS Dasa
              wrote on last edited by
              #6

              The following is the code for the dropdownlist... written in ASP to pump the html code. The first drop down is for the CITY, and the other for the CATEGOREY. <% Response.Write "" Response.Write "Select City" for ii=1 to temp_rs.RecordCount if (Request ("srchCat") = temp_rs ("City")) then selOpt = "selected" else selOpt = "" end if Response.Write "" & temp_rs ("City") & "" temp_rs.MoveNext next Response.Write "" Response.Write "" Response.Write "Select Category" Response.Write "" %> The following is the JSCRIPT and ASP combined stuff...... <!-- var groups = document.drsrchform.City.options.length var group = new Array(groups) // alert ("Hai"); for (i=0; i<groups; i++) group[i]=new Array() <% Dim curVal, cityCnt, catCnt, curCity cityCnt = 1 catCnt = 0 set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security Info=False;" & "Data Source=" &Server.MapPath(drDatabase) Set temp_rs = Server.CreateObject("ADODB.RecordSet") SqlStr= "SELECT distinct Category, City FROM DocDetails where Country='XXX' order by City" temp_rs.Open SqlStr, conn, 1,3 curCity = temp_rs ("City") Do While not temp_rs.EOF curVal = temp_rs ("Category") if (curCity <> temp_rs("City")) then cityCnt = cityCnt + 1 catCnt = 0 curCity = temp_rs ("City") end if %> // alert ("<%=curVal%>" + " <%=cityCnt%>" + " <%=catCnt%>"); group[<%=cityCnt%>][<%=catCnt%>] = new Option ("<%=curVal%>","<%=curVal%>"); <% catCnt = catCnt + 1 temp_rs.MoveNext loop set temp_rs=nothing set Conn=nothing %> var temp=document.drsrchform.Category function redirect(x) { for (m=temp.options.length-1;m>0;m--) temp.options[m]=null for (i=0;i<group[x].length;i++) { temp.options[i]=new Option(group[x][i].text,group[x][i].value) } temp.options[0].selected=true } //--> Please notice that... if there is ANY change in the name of the vars/anything... this wont wont work. Hav

              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