two dropdown list getting data from access table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhi3211
    New Member
    • Mar 2008
    • 3

    two dropdown list getting data from access table

    i am using java inside java script page.
    in that page i want to use two dropdown list.
    in first dropdown list i am getting data from ms-access database.
    in second dropdown list i want to get data according to selection made in first dropdown list and it will also come from ms-access database.(for example if i am selecting country as india in first dropdown list then in second dropdown list will show states of india)

    the problem is that i am not able to get the proper result in second dropdown list
    i will be thankful if you give me proper solution to my problem
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by abhi3211
    i am using java inside java script page.
    in that page i want to use two dropdown list.
    in first dropdown list i am getting data from ms-access database.
    in second dropdown list i want to get data according to selection made in first dropdown list and it will also come from ms-access database.(for example if i am selecting country as india in first dropdown list then in second dropdown list will show states of india)

    the problem is that i am not able to get the proper result in second dropdown list
    i will be thankful if you give me proper solution to my problem
    Why don't you post the code that you have and explain explain the results you want to get.

    Comment

    • abhi3211
      New Member
      • Mar 2008
      • 3

      #3
      Originally posted by r035198x
      Why don't you post the code that you have and explain explain the results you want to get.

      the first dropdown list is for displaying project name and second dropdown list is for displaying approver name associated with selected project name in first dropdown list.
      the problem is in second dropdown list the required data is not comming

      <!-- project Name drop-down list -->


      <tr>
      <td><b><font color=blue>Proj ect Name</font></b></td>

      <% String CategoryCombo = null;%>

      <td><SELECT NAME="pname" id= pname tabindex=5 onchange=locati on.href='pic_de mo.jsp?option'= +this.value;>
      <%
      Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") .newInstance();
      Connection conn = DriverManager.g etConnection("j dbc:odbc:Cab");
      Statement statement = conn.createStat ement();
      ResultSet rs = statement.execu teQuery("select projname from login where desgn<>'A' group by projname");%>
      <OPTION VALUE=0>Choose Project Name</OPTION>";
      <%
      while(rs.next() )
      {
      CategoryCombo = rs.getString("p rojname");%>
      <option value='<%=Categ oryCombo%>' /><%out.println( CategoryCombo); %></option>
      <% } %>

      </SELECT></td>
      </tr>


      <!--- This is for approver dropdownlist --->

      <tr>
      <td><b><font color=blue>Appr over</font></b></td>

      <%
      String ApproverCombo = null;%>
      <td><SELECT NAME="Approver" id =Approver tabindex=6>
      <OPTION VALUE=0>Choose Approver Name</OPTION>";
      <%
      ResultSet ss = statement.execu teQuery("SELECT name from login where desgn='M' and projname='<%=Ca tegoryCombo%>' ");
      while(ss.next() )
      {
      ApproverCombo = ss.getString("n ame");%>
      <option value='<%=Appro verCombo%>' /><%out.println( ApproverCombo); %></option>
      <% }
      %>
      </SELECT>

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        That won't work. Remember the Java code is processed at the server and the Javascript at the client. Either use AJAX or load all the required values into a Javascript array on page load. You can then manipulate those values (select which ones to display) using Javascript on the client side based on the user's input.

        Comment

        • abhi3211
          New Member
          • Mar 2008
          • 3

          #5
          Originally posted by r035198x
          That won't work. Remember the Java code is processed at the server and the Javascript at the client. Either use AJAX or load all the required values into a Javascript array on page load. You can then manipulate those values (select which ones to display) using Javascript on the client side based on the user's input.

          thanks for your reply..
          i am new to jsp. can you send me code for this all and how to use AJAX in this case because i have to populate both dropdoun list from database..

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by abhi3211
            thanks for your reply..
            i am new to jsp. can you send me code for this all and how to use AJAX in this case because i have to populate both dropdoun list from database..
            The codes for that has been written thousands of times and is available all over the internet including in our very own Javascript/AJAX forum

            Comment

            Working...