Loading ...
Sorry, an error occurred while loading the content.

Re: [ASP] dropdown

Expand Messages
  • Lil Peck
    I put together an upload script that may be of interest to some of you. You can get it from http://quarter-horse-times.com/aspexamples/tozip/Gallerylist.asp It
    Message 1 of 8 , Mar 2, 2004
    View Source
    • 0 Attachment
      I put together an upload script that may be of interest to some of you. You
      can get it from
      http://quarter-horse-times.com/aspexamples/tozip/Gallerylist.asp
      It uploads an image to folder while inserting filename into database. An
      updated version will do that or edit an existing filename record while
      uploading a new file.
      I can't claim this is original code. I mostly adapted code that was done by
      Lewis Moten.

      Lil Peck "A Few Good Horses For Sale"
      840 Stadel Rd
      Manhattan KS 66502-7009
      785-537-0735
      LilPeck@...
      DreamHorse.com video technician
      Web Design, web video, web programming, automation
      Graphics, logos, music
      "ASK ME" about web hosting and design!
    • Mark E
      Hari, From the looks of your function name, it appears that you are trying to call this client-side, not server-side. Please post all of your code so that we
      Message 2 of 8 , Mar 2, 2004
      View Source
      • 0 Attachment
        Hari,

        From the looks of your function name, it appears that you are trying to call this client-side, not server-side.

        Please post all of your code so that we can see it.

        Thanks,
        Mark

        "Krishna, Hari" <hkrishna@...> wrote:
        Mark,

        I am not able to get the recordset.
        I changed a little bit to help myself. Why am I not able to get to the
        recordset..????

        VBScript.......
        function SLine_OnChange()
        slcode = document.Frontpage_Form1.SLine.value
        document.writeln "I am in" & "<br>" & slcode & "<br>" Upto this
        point it works well but it always prints value as 1.

        sltext = document.Frontpage_Form1.SLine.options[slcode].text
        document.writeln "I am in" & "<br>" & sltext ''(I am not getting the
        text value of the dropdown list)



        Set DB2 = Server.CreateObject("ADODB.Connection")
        Set RSList = Server.CreateObject("ADODB.Recordset")

        DB2.Open "DSN=Web; UID=web; PWD=web"
        sSQL_dpt = "Select Dept_No,Dept_Name From depts where Service_Line =
        Hos"
        document.writeln "I am in" & "<br>" & sSQL_dpt 'I am not able to
        print this sql statement
        RSList.Open sSQL_dpt, DB2


        DB2.close
        set DB2=nothing
        end function

        Thanks,
        Hari

        -----Original Message-----
        From: Mark E [mailto:meckeard2000@...]
        Sent: Tuesday, March 02, 2004 12:29 PM
        To: active-server-pages@yahoogroups.com
        Subject: Re: [ASP] dropdown


        Hari,

        What exactly is happening? Are you getting an error when trying to retrieve
        the second recordset? Or can you get the records but not populate the
        second dropdown list?

        Mark

        "Krishna, Hari" <hkrishna@...> wrote:
        Guys,

        Sorry to ask this question as this might have been answered earlier.

        I couldnot find an effective and simple solution to this.

        I have two dropdown combos.

        I could populate the first combo. Based on the selection, I need to goback
        to database and get the results and populate the second combo based on the
        selection in first combo.

        I could call the javaScript. But I donot know how to send the recordset back
        or access the recordset to populate the dropdown.

        I am certainly able to pass a value back from the javascript, but the
        recordset.

        I tried to do the following function and call it and it didnot work.

        <%
        function RSGetDept(sercode)
        response.write "I am in"

        Set DB2 = Server.CreateObject("ADODB.Connection")
        Set RSList = Server.CreateObject("ADODB.Recordset")

        DB2.Open "DSN=dsn; UID=uid; PWD=pwd"
        sSQL_dpt = "Select Dept_No,Dept_Name From dept where Service_Line =
        '" & sercode & "'"

        RSList.Open sSQL_dpt, DB2


        DB2.close
        set DB2=nothing
        end function

        %>

        Can someone help me understand this? What am I missing?
        I did check the aspfaq but didnot help. I checked the atgconsulting solution
        but it doesnot connect to the database back to get the results.

        thanks a bunch.
        Hari


        CONFIDENTIALITY NOTICE:
        This e-mail message, including all attachments, is for the sole use of the
        intended recipient(s) and may contain confidential and privileged
        information. You may NOT use, disclose, copy or disseminate this
        information. If you are not the intended recipient, please contact the
        sender by reply e-mail immediately. Please destroy all copies of the
        original message and all attachments. Your cooperation is greatly
        appreciated.
        Columbus Regional Hospital
        2400 East 17th Street
        Columbus, Indiana 47201


        ---------------------------------------------------------------------
        Home : http://groups.yahoo.com/group/active-server-pages
        ---------------------------------------------------------------------
        Post : active-server-pages@yahoogroups.com
        Subscribe : active-server-pages-subscribe@yahoogroups.com
        Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
        ---------------------------------------------------------------------



        ---------------------------------
        Yahoo! Groups Links

        To visit your group on the web, go to:
        http://groups.yahoo.com/group/active-server-pages/

        To unsubscribe from this group, send an email to:
        active-server-pages-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



        ---------------------------------
        Do you Yahoo!?
        Yahoo! Search - Find what you're looking for faster.

        [Non-text portions of this message have been removed]



        ---------------------------------------------------------------------
        Home : http://groups.yahoo.com/group/active-server-pages
        ---------------------------------------------------------------------
        Post : active-server-pages@yahoogroups.com
        Subscribe : active-server-pages-subscribe@yahoogroups.com
        Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
        ---------------------------------------------------------------------
        Yahoo! Groups Links







        CONFIDENTIALITY NOTICE:
        This e-mail message, including all attachments, is for the sole use of the
        intended recipient(s) and may contain confidential and privileged
        information. You may NOT use, disclose, copy or disseminate this
        information. If you are not the intended recipient, please contact the
        sender by reply e-mail immediately. Please destroy all copies of the
        original message and all attachments. Your cooperation is greatly
        appreciated.
        Columbus Regional Hospital
        2400 East 17th Street
        Columbus, Indiana 47201


        ---------------------------------------------------------------------
        Home : http://groups.yahoo.com/group/active-server-pages
        ---------------------------------------------------------------------
        Post : active-server-pages@yahoogroups.com
        Subscribe : active-server-pages-subscribe@yahoogroups.com
        Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
        ---------------------------------------------------------------------



        ---------------------------------
        Yahoo! Groups Links

        To visit your group on the web, go to:
        http://groups.yahoo.com/group/active-server-pages/

        To unsubscribe from this group, send an email to:
        active-server-pages-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



        ---------------------------------
        Do you Yahoo!?
        Yahoo! Search - Find what you�re looking for faster.

        [Non-text portions of this message have been removed]
      • Krishna, Hari
        Hello Folks, I have accomplished the task what I was looking to do. Populate the second dropdown combo with data from the database(connect to database to pull
        Message 3 of 8 , Mar 3, 2004
        View Source
        • 0 Attachment
          Hello Folks,

          I have accomplished the task what I was looking to do. Populate the second
          dropdown combo with data from the database(connect to database to pull the
          values) based on the selection from the first dropdown list.

          Thanks for any help.

          Rgds,
          Hari


          CONFIDENTIALITY NOTICE:
          This e-mail message, including all attachments, is for the sole use of the
          intended recipient(s) and may contain confidential and privileged
          information. You may NOT use, disclose, copy or disseminate this
          information. If you are not the intended recipient, please contact the
          sender by reply e-mail immediately. Please destroy all copies of the
          original message and all attachments. Your cooperation is greatly
          appreciated.
          Columbus Regional Hospital
          2400 East 17th Street
          Columbus, Indiana 47201
        • Cadieux.Tim@fin.gc.ca
          Can u post the final code so we can all see what you did? Tim ... From: Krishna, Hari [mailto:hkrishna@crh.org] Sent: March 3, 2004 5:48 PM To:
          Message 4 of 8 , Mar 4, 2004
          View Source
          • 0 Attachment
            Can u post the final code so we can all see what you did?

            Tim

            -----Original Message-----
            From: Krishna, Hari [mailto:hkrishna@...]
            Sent: March 3, 2004 5:48 PM
            To: 'active-server-pages@yahoogroups.com'
            Subject: RE: [ASP] dropdown

            Hello Folks,

            I have accomplished the task what I was looking to do. Populate the second
            dropdown combo with data from the database(connect to database to pull the
            values) based on the selection from the first dropdown list.

            Thanks for any help.

            Rgds,
            Hari


            CONFIDENTIALITY NOTICE:
            This e-mail message, including all attachments, is for the sole use of the
            intended recipient(s) and may contain confidential and privileged
            information. You may NOT use, disclose, copy or disseminate this
            information. If you are not the intended recipient, please contact the
            sender by reply e-mail immediately. Please destroy all copies of the
            original message and all attachments. Your cooperation is greatly
            appreciated.
            Columbus Regional Hospital
            2400 East 17th Street
            Columbus, Indiana 47201



            ---------------------------------------------------------------------
            Home : http://groups.yahoo.com/group/active-server-pages
            ---------------------------------------------------------------------
            Post : active-server-pages@yahoogroups.com
            Subscribe : active-server-pages-subscribe@yahoogroups.com
            Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
            ---------------------------------------------------------------------
            Yahoo! Groups Links
          • Krishna, Hari
            function Java_populate(caob) { if (caob.status != -1) { eval(caob.return_value); //alert(caob.return_value); var str_return = caob.return_value; var seprtr =
            Message 5 of 8 , Mar 5, 2004
            View Source
            • 0 Attachment
              function Java_populate(caob)
              {
              if (caob.status != -1)
              {
              eval(caob.return_value);
              //alert(caob.return_value);
              var str_return = caob.return_value;
              var seprtr = ',';
              var strArray = str_return.split(seprtr);
              var sec_str = strArray[1];
              var sec_sep = "'";
              var sec_strArray = sec_str.split(sec_sep);
              FrontPage_Form1.dept_name.value = sec_strArray[1];
              }
              }


              function Get_Mgr ()
              {
              FrontPage_Form1.dept_name.value = "";
              var sl =
              document.FrontPage_Form1.SLine.options[document.FrontPage_Form1.SLine.select
              edIndex].text;
              var str1 = sl ;

              while (RSAspProxyApplet.readyState != 4) {}
              while (RSAspProxyApplet.readyState != 4) {}
              var dno1 = sl;

              RSExecute("http://www.webserver.com/test/RS_GetListBoxTest.asp","RSGetList",
              'FrontPage_Form1.depnum',dno1,Java_populate);

              }

              '----This is for onchange of the department number that I need to get dept
              name...I could have used arrays here insetad of 'making calls to the
              datasbase.........


              function Get_deptname ()
              {

              empty = "Blank1";
              var dept1 =
              document.FrontPage_Form1.depnum.options[document.FrontPage_Form1.depnum.sele
              ctedIndex].text;
              var dno1 = dept1;
              while (RSAspProxyApplet.readyState != 4) {}
              while (RSAspProxyApplet.readyState != 4) {}
              co2 =
              RSExecute("http://www.webserver.com/test/RS_GetListBoxTest.asp","RSGetDeptNa
              me",empty,dno1);
              FrontPage_Form1.dept_name.value = co2.return_value;

              }


              onchange of the dropdown combo, I call the get_mgr()

              Remote scripting goes like this.............

              <% RSDispatch %>
              <!--#INCLUDE VIRTUAL="/_ScriptLibrary/rs.asp"-->

              <SCRIPT RUNAT=SERVER Language=javascript>

              function Description()
              {
              this.RSGetList = Function("lbname","make","return
              RSGetListBox(lbname,make)");
              this.RSGetDeptName = Function("d11","d22","return
              RSGetDeptName(d11,d22)");
              }
              public_description = new Description();
              </SCRIPT>

              <SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
              var public_description = new MyServerMethods();
              function MyServerMethods()
              {
              this.RSGetList = Function("lbname","make","return
              RSGetListBox(lbname,make)");
              this.RSGetDeptName = Function("d11","d22","return
              RSGetDeptName(d11,d22)");
              }
              </SCRIPT>

              <%
              '--------------------------------
              '--this is our function that is called by the client
              function RSGetDeptName(d11,d22)
              Dim Edc_name
              Dim DB2, RSList, sList
              Set DB2 = Server.CreateObject("ADODB.Connection")
              Set RSList = Server.CreateObject("ADODB.Recordset")
              DB2.Open "DSN=dsn; UID=uid; PWD=pwd"
              sList = "Select Distinct Dept_Name From Job_Positions where Dept_No
              = '" & d22 & "'"
              RSList.Open sList, DB2
              if RSList.eof or RSList.bof then
              'No Data found
              dep_name= "_________" & "#" & "_________"
              else

              Edc_name=RSList(0)
              end if
              RSGetDeptName=depc_name
              RSList.close
              set RSList=nothing
              DB2.close
              set DB2=nothing
              end function
              function RSGetListBox(lbname,make)
              dim SQL
              make = replace(make,"'", "''") 'I did use this because make can be
              woman's
              SQL = "SELECT DISTINCT dept_no, dept_name, dept_no1, dept_name1 FROM
              Job_Positions WHERE "
              SQL = "service_line = '" & make & "' Order by dept_No"
              RSGetListBox=DropDownBox(lbname,SQL)
              end function


              function DropDownBox(lbname,SQL)
              dim comma,x,conn,rx,col1,col2
              dim ret_var
              Dim DB_LB, RS_LB, sSQL_LB

              Set DB_LB = Server.CreateObject("ADODB.Connection")
              Set RS_LB = Server.CreateObject("ADODB.Recordset")

              DB_LB.Open "DSN=dsn; UID=uid; PWD=pwd"

              comma=""
              x=0
              ret_var = ret_var & "var lb1=" & lbname & ";"
              ret_var = ret_var & "var arr=new Array("

              RS_LB.Open SQL, DB_LB
              do while not RS_LB.eof
              col1=replace(trim(cstr(RS_LB(0) & "")),"'","\'")
              col2=replace(trim(cstr(RS_LB(3) & "")),"'","\'")
              ret_var = ret_var & comma & col1
              comma=","
              ret_var= ret_var & comma & col2
              x=x+1
              RS_LB.movenext
              loop
              RS_LB.close
              DB_LB.close
              ret_var= ret_var& ");"

              'instruct javascript to populate the dropdown menu
              ret_var = ret_var& "lb1.length=0;"
              ret_var= ret_var& "var x=0;"
              ret_var= ret_var& "while (x < arr.length) {"
              ret_var= ret_var& "lb1.options[lb1.length] = new
              Option(arr[x]);" '###,arr[x+1]);"
              ret_var= ret_var& "x=x+2;}"
              DropDownBox = ret_var

              End function


              %>


              -------I used the array because I had to manipulate some other things that
              are not shown here. THis is just a basic program that serves the purpose.


              -----Original Message-----
              From: Cadieux.Tim@... [mailto:Cadieux.Tim@...]
              Sent: Thursday, March 04, 2004 8:31 AM
              To: active-server-pages@yahoogroups.com
              Subject: RE: [ASP] dropdown


              Can u post the final code so we can all see what you did?

              Tim

              -----Original Message-----
              From: Krishna, Hari [mailto:hkrishna@...]
              Sent: March 3, 2004 5:48 PM
              To: 'active-server-pages@yahoogroups.com'
              Subject: RE: [ASP] dropdown

              Hello Folks,

              I have accomplished the task what I was looking to do. Populate the second
              dropdown combo with data from the database(connect to database to pull the
              values) based on the selection from the first dropdown list.

              Thanks for any help.

              Rgds,
              Hari


              CONFIDENTIALITY NOTICE:
              This e-mail message, including all attachments, is for the sole use of the
              intended recipient(s) and may contain confidential and privileged
              information. You may NOT use, disclose, copy or disseminate this
              information. If you are not the intended recipient, please contact the
              sender by reply e-mail immediately. Please destroy all copies of the
              original message and all attachments. Your cooperation is greatly
              appreciated.
              Columbus Regional Hospital
              2400 East 17th Street
              Columbus, Indiana 47201



              ---------------------------------------------------------------------
              Home : http://groups.yahoo.com/group/active-server-pages
              ---------------------------------------------------------------------
              Post : active-server-pages@yahoogroups.com
              Subscribe : active-server-pages-subscribe@yahoogroups.com
              Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
              ---------------------------------------------------------------------
              Yahoo! Groups Links









              ---------------------------------------------------------------------
              Home : http://groups.yahoo.com/group/active-server-pages
              ---------------------------------------------------------------------
              Post : active-server-pages@yahoogroups.com
              Subscribe : active-server-pages-subscribe@yahoogroups.com
              Unsubscribe: active-server-pages-unsubscribe@yahoogroups.com
              ---------------------------------------------------------------------
              Yahoo! Groups Links







              CONFIDENTIALITY NOTICE:
              This e-mail message, including all attachments, is for the sole use of the
              intended recipient(s) and may contain confidential and privileged
              information. You may NOT use, disclose, copy or disseminate this
              information. If you are not the intended recipient, please contact the
              sender by reply e-mail immediately. Please destroy all copies of the
              original message and all attachments. Your cooperation is greatly
              appreciated.
              Columbus Regional Hospital
              2400 East 17th Street
              Columbus, Indiana 47201
            Your message has been successfully submitted and would be delivered to recipients shortly.