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

Recommended Answers

All 2 Replies

hello guys,
i just found out lately when i run this on firefox i got the result, but running it under
internet explorer would not reflect any changes on the list. i'm seeking advise from the
experts to enlighten me. please help :)

It probably has got something to do with a faulty javascript snippet dealing with Ajax. A lightweight library along the lines of 'Ajax Toolbox' might just make your pain go away. If not, take a look at the IE debuggers out there to assist you in finding the problematic piece of code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.