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 8795793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:28:03+00:00 2026-06-13T23:28:03+00:00

I am sending multiselect dropdown values to a JSP PAGE. Below is the AJAX

  • 0

I am sending multiselect dropdown values to a JSP PAGE. Below is the AJAX code that send the multiselect values. The JSP PAge includes SQL query to read from database and show its values in another dropdown. Below code only display cascading dropdown values based on on select and not multiselect. It appears that only one value is sent to apps.jsp and not all values. I tried few changes and it didn’t work. Below is the best working code available with me. Any help to get second dropdown display values based on multiselect from first dropdown? Single dropdown works fine with below code. Thank you.

<select multiple="multiple" name="RequirementFor" id="RequirementFor" onchange="showState(this.value);">

 <option value="1">Test1</option>
    <option value="2">Test2</option>
<option value="3">Test3</option>
<option value="4">Test4</option>
</select>
<div id="plat"><select name="Platform" id="Platform"  multiple="multiple"     onchange='showState2(this.value)'>

    </select></div>
//AJAX Code
var xmlHttp ; 
var xmlHttp;
function showState(str){

if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert("Browser does not support XMLHTTP Request");
return;
} 
var url="apps.jsp";
url +="?value=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function stateChange(){   
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
document.getElementById("plat").innerHTML=xmlHttp.responseText   ;
}
}

below is code from JSP query(apps.jsp) page.

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost", "username", "password"); 
Statement stmt;
ResultSet rs;
String[] funID=  request.getParameterValues("value");  
String conCat = "";
try{
if(funID.length>0)
{
for(int i=0;i<funID.length; i++)
{
    conCat =    funID[i] +" "+ "OR" + " "+ "FU_DEPARTMENT_ID= " + conCat;
} 
conCat = conCat.substring(0, conCat.length() - 22);
}
}
 catch(Exception e)
 {out.println(e);}

 String buffer="<select name='state' multiple='multiple'><option value='-1'>Select</option>";


 try
 {

        String sqlSelect1="Select FU_ID, FU_NAME from UNIT where FU_DEPARTMENT_ID ="+conCat+" ORDER BY FU_NAME ASC";

  stmt = con.createStatement();  
 rs = stmt.executeQuery(sqlSelect1);  
   while(rs.next()){
   buffer=buffer+"<option value='"+rs.getString("FU_ID")+"'>"+rs.getString("FU_NAME")+"</option>";  
   }  
 buffer=buffer+"</select>";  
 response.getWriter().println(buffer); 
 stmt.close();
 rs.close();
 con.close();
 }
 catch(Exception e){
     System.out.println(e);
 }
  • 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-13T23:28:05+00:00Added an answer on June 13, 2026 at 11:28 pm

    I think you should change the way you get multi-values. Some thing likes this:

        <select multiple="multiple" name="RequirementFor" id="RequirementFor" onchange='getMultiple(this);'>
        <option value="1">Test1</option>
        <option value="2">Test2</option>
        <option value="3">Test3</option>
        <option value="4">Test4</option>
    </select>
    
    <script>
        var selected; 
        function getMultiple(ob) { 
            selected = new Array();
            for (var i = 0; i < ob.options.length; i++) {
                if (ob.options[ i ].selected) {
                    selected.push(ob.options[ i ].value);
                }
            }
            var str = "";
        for (var i = 0; i < selected.length; i++) {
            str += "&value=" + selected[i];
        }
        console.log(str);
    
                // --> your ajax code
    
        }
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

M sending the parameters from the jsp page, the code is <s:url id=url action=searchAction>
I sending ajax request from a jQuery file like below, which expects response in
Form sending AJAX code: var str = $(form).serialize(); alert(str); // var uns=@unserialize(str); //alert(uns); $.ajax({
I sending a message with this code below and works: $headers = 'From: Online
I want to make a pop-up page that contains a listbox-type (multiselect) control which
When sending a sendOrderedBroadcast with an ACTION_MEDIA_BUTTON intent (I'm imitating that the user is
When sending data from a form to a second page, the value of the
I'm sending POST data from text boxes to a PHP page for processing. Rather
I am sending sensitive information to my users that I would like them to
Sending the below request in my phonegapp-ed android app works for GET but not

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.