Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8230975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:19:08+00:00 2026-06-07T17:19:08+00:00

I have two html drop down list, their value are retrieved from the database

  • 0

I have two html drop down list, their value are retrieved from the database by using jsp.

<%
  String query =" SELECT question_text,question_id FROM questions WHERE id = ?";
   PreparedStatement stmt = conn.prepareStatement(query);
   stmt.setString(1,request.getParameter("QID"));
   ResultSet rs = stmt.executeQuery();
    if(!rs.next()) {} else {%>
   <form action="#" method="post">
   <p> First Question </p>
   <select name="currentQuestion">
<%do{%> 
<option value="<%=rs.getString("question_id")%>"><%=rs.getString("question_text")%>  </option>
<%}while(rs.next());}%>
</select>

<%                  
  String query =" SELECT question_text,question_id FROM questions WHERE id = ? AND question id != ? ";
  PreparedStatement stmt = conn.prepareStatement(query);
  stmt.setString(1,request.getParameter("QID"));
  stmt.setString(2,CHOOSEN QUESTION);
  ResultSet rs = stmt.executeQuery();
  if(!rs.next()) {} else {%>
  <p> Next Question </p>
 <select name="currentQuestion">
 <%do{%>    
  <option value="<%=rs.getString("question_id")%>"><%=rs.getString("question_text")%></option>
 <%}while(rs.next());}%>
  </select>
  </form>       

Now, I what when the user choose a specific question from the first drop down list, the value of the second drop down list does not include that question ?
is anyone know how to do that ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:19:09+00:00Added an answer on June 7, 2026 at 5:19 pm
    1. You don’t set CHOOSEN QUESTION anywhere in the code.
    2. You forgot he id and name tags in the option element.
    3. CHOOSEN QUESTION is an illegal name for a variable since it contains a space.
    4. You can’t do it the way you’re trying to do, cause this code runs on the server-side before the user chooses an option. What you probably want to do is load all the options (if there aren’t too many of them) and create a JS/jQuery that will refresh the second dropbox on the event onChange of the first dropbox (before the user chooses an option – you’ll probably want to have the second dropbox disabled)
    5. Another thing that you probably want to do is create a form which will eventually submit the user’s choices to a JSP (server-side).
    6. You can also achieve the same behavior using AJAX, you can find an example of how to do it here.

    UPDATE (example code for changing options using JS):

    <html>
    <head>
    <script type="text/javascript" >
    <!-- hide
    
    function update(x){
        if (x != "null") {
            if (x == "1") {
                var jumpmenu2 = document.getElementById("jumpmenu2");
                var newOption1 = document.createElement('option');
                newOption1.text = "a"; //HERE You'll use newOption1.text = "<?php echo $db_option_text;?>"; 
                newOption1.value = "1"; //HERE You'll use newOption1.text = "<?php echo $db_option_value;?>"; 
                var newOption2 = document.createElement('option');
                newOption2.text = "b"; // same like above
                newOption2.value = "2"; // same like above
                var newOption3 = document.createElement('option');
                newOption3.text = "c"; // same like above
                newOption3.value = "3"; // same like above
                jumpmenu2.remove(jumpmenu2.length-1);
                jumpmenu2.remove(jumpmenu2.length-1);
                jumpmenu2.remove(jumpmenu2.length-1);
                try {
                    // For standard browsers
                    jumpmenu2.add(newOption1,null);
                    jumpmenu2.add(newOption2,null);
                    jumpmenu2.add(newOption3,null);
                }
                catch (ex) {
                    // For Microsoft Internet Explorer and other non-standard browsers.
                    jumpmenu2.add(newOption1);
                    jumpmenu2.add(newOption2);
                    jumpmenu2.add(newOption3);
                }
            }
            else if (x == "2"){
                var jumpmenu2 = document.getElementById("jumpmenu2");
                var newOption1 = document.createElement('option');
                newOption1.text = "d";
                newOption1.value = "1";
                var newOption2 = document.createElement('option');
                newOption2.text = "e";
                newOption2.value = "2";
                var newOption3 = document.createElement('option');
                newOption3.text = "f";
                newOption3.value = "3";
                jumpmenu2.remove(jumpmenu2.length-1);
                jumpmenu2.remove(jumpmenu2.length-1);
                jumpmenu2.remove(jumpmenu2.length-1);
                try {
                    // For standard browsers
                    jumpmenu2.add(newOption1,null);
                    jumpmenu2.add(newOption2,null);
                    jumpmenu2.add(newOption3,null);
                }
                catch (ex) {
                    // For Microsoft Internet Explorer and other non-standard browsers.
                    jumpmenu2.add(newOption1);
                    jumpmenu2.add(newOption2);
                    jumpmenu2.add(newOption3);
                }
            }
        }
    }
    
    // end hide -->
    </script>
    </head>
    <body>
    <form name="form1" id="form1">
    <select name="jumpmenu" name="jumpmenu" onChange="update(document.form1.jumpmenu.options[document.form1.jumpmenu.options.selectedIndex].value)">
    <option value=1>1</option>
    <option value=2>2</option>
    </select>
    </form>
    <select name="jumpmenu2" id="jumpmenu2">
    <option value=a id=1>a</option>
    <option value=b id=2>b</option>
    <option value=c id=3>c</option>
    </select>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using html SELECT to make 3 drop-down menus. One for a list of
I have a drop-down list box and two text fields of id values namely
I have a page with a ScriptManager, a generic HTML drop-down list ( <select>
I have two dropdown list and an inputbox. When a value from the dropdown
I have created a populated dropdown list in HTML. When the two dropdowns have
I have a C#.Net MVC3 web app. I am using Drop Down lists all
I'm trying to get drop down list in Cake for below two finds by
Form contains two dropdown lists created using code below. Both dropdown list elements have
I have a 3-level deep, unordered list I'm styling to create a drop-down menu
I have two dropdowns @using (Html.BeginForm()) { <fieldset> <legend></legend> <label>User details</label> <section> @Html.LabelFor(model =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.