hello guys,
good day!
i would like to seek for help regarding on how to cascade drop down list using struts tag <html:select> with ajax. it goes like this. drop down list 'A' is the list for Car Brands and drop down list 'B' is for the Car models by brand. what i wanted to do is that drop down list 'B' will show up the available car models according to the selection i made from drop down list 'A'. here is the following code i made: (for this example i would just like to generate
a simple example under <html:select>).
--------------------------------------------------
on my main jsp page:
<html:select property="brands" onchange="showModels()">
// some code
</html:select>
<html:select property="models" styleId="modelList">
</html:select>
on my jsp page to be loaded: WEB-INF/jsp/models.jsp
<html:option value="0">corola 1234</html:option>
<html:option value="1">corola 5678</html:option>
on my javascript:
function showModels() {
// some code here
var url = "models.do";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChanged() {
if(xmlHttp.readyState==4) {
if(xmlHttp.status==200) {
document.getElementById("modelList").innerHTML=xmlHttp.responseText;
} else {
alert("there was a problem on the requested page");
}
}
}
--------------------------------------------------
the problem is i could not generate the list option from models.jsp. please help. :(
thanks in advance.
`gray