View Single Post
Old 11-06-2012, 03:22 AM   PM User | #1
naveendk.55
New Coder

 
Join Date: Aug 2011
Posts: 88
Thanks: 5
Thanked 0 Times in 0 Posts
naveendk.55 is an unknown quantity at this point
Post sending Multiselect values using ajax

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.


Code:
<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   ;
}
}
I am using below JSP code to read arrary of values:

PHP Code:
String[] funID=  request.getParameterValues("value"); 
naveendk.55 is offline   Reply With Quote