populate drop-down values dynamically using Ajax
        Posted  
        
            by abhishek
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by abhishek
        
        
        
        Published on 2010-01-05T08:56:04Z
        Indexed on 
            2010/03/27
            16:03 UTC
        
        
        Read the original article
        Hit count: 266
        
Hi,
I have 3 drop-downs. 1st drop-down contains some values when the page loads. I need to populate 2 nd drop-down based on the value selected in 1st dropdown. Similarly, I need to populate 3 nd drop-down based on the value selected in 1st and 2nd dropdown.
Initially I tried like this.
 <h:selectOneMenu value="#{stu.country}" >
  <f:selectItems value="#{bean.allCountries}" />
  <a4j:support event="onchange"  action="#{bean.retrieveStates(stu.country)}"  
  reRender="states_dropDown"></a4j:support>
   </h:selectOneMenu>
//ly, for 2nd drop-down
    <h:selectOneMenu id="states_dropDown" value="#{stu.state}" >
      <f:selectItems value="#{bean.allStates}" />
    <a4j:support event="onchange"  
     action="#{bean.retrieveCities(stu.country,stu.state)}"  
     reRender="City_dropDown"></a4j:support>
       </h:selectOneMenu>
Some times this code works fine. But some times it doesn't invoke managed bean method.
Can you please help??
© Stack Overflow or respective owner