Populate/fill second conbo box values based on first combo box selection.

Sample Code
<aui:script>
AUI().ready('aui-dialog',"node",function(A){
          A.one("#<portlet:namespace />country").on("change",function(e){
var countrySelect=  A.one("#country").val();
A.one("#<portlet:namespace />state").val("");
if(countrySelect == "CA"){
document.<portlet:namespace />fm.state.options.length=0;
document.<portlet:namespace />fm.state.options[0]=new Option("Select State...","");
                     document.<portlet:namespace />fm.state.options[1]=new Option("Canada State1","LA");
                     document.<portlet:namespace />fm.state.options[2]=new Option("Canada State2","LA2");
A.one("label[for='state']").html("Province ");  //Replace the state label to Province
}else{
document.<portlet:namespace />fm.state.options.length=0;
document.<portlet:namespace />fm.state.options[0]=new Option("Select State...","");
document.<portlet:namespace />fm.state.options[1]=new Option("Los angiles","LA");
document.<portlet:namespace />fm.state.options[2]=new Option("Los angiles1","LA1");
A.one("label[for='state']").html("State ");
}
         });

});
<!--<span class="hiddenSpellError" pre=""-->aui:script>
<aui:form name="fm" method="post">
<table>
<tr>
<td><label for="country">Country</label></td>
<aui:select label="" name="country">
<aui:option value="">Select Country...
<aui:option value="US">United State
<aui:option value="CA">Canada
<!--<span class="hiddenSpellError" pre=""-->aui:select>
</tr>
<tr>
&nbsp;
</tr>
<tr>
<td><label for="state">State </label></td>
<aui:select label="State" name="state" label="">
<aui:option value="">Select Country...
<!--<span class="hiddenSpellError" pre=""-->aui:select>
</tr>
</table>
<!--<span class="hiddenSpellError" pre=""-->aui:form>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: