Here are the list

1. 1st Dropdown
Code:
    COUNTRY_ID   COUNTRY
    01                  AMERICA
    02                  AUSTRALIA
    03                  BELGIUM
    04                  LUXEMBOURG
    05                  RUSSIA
2. 2nd Dropdown
Code:
    COUNTRY_ID   STATE_ID       STATE
    01                  0101               ALASKA
    01                  0102               WASHINGTON
    01                  0103               TEXAS
    02                  0201               VICTORIA
    02                  0202               QUEENSLAND
    03                  0301               WEST-VLAANDEREN    03                  0302               ANTWERPEN
    04                  0401               LUXEMBOURG
    05                  0501               MOSCOW
    05                  0502               ST. PETERSBURG
and here's the coding (javascipt)
Code:
<h:panelGroup>
      <h:selectOneMenu id="country" required="true" value="#{world.country}">
            <f:selectItem itemLabel="#{msgreg['registration.new.choose']}" itemValue="" />
                                                                    <f:selectItems value="#{listCountry.all}" id="a4" />
                                                                    <t:jsValueChangeListener for="District"
                                                                        expressionValue="updateDropDown($srcElem, $destElem, '#{world.state}', 'list_state');" />
                                                                </h:selectOneMenu>
                                                                <h:outputText value="&nbsp" escape="false" />
                                                                <h:outputText value="*" styleClass="formnotes" />
                                                            </h:panelGroup>

                                                            <h:panelGroup>
                                                                <h:selectOneMenu id="State" required="true"
                                                                    value="#{world.state}">
                                                                    <f:selectItem
                                                                        itemLabel="#{msgreg['registration.new.choose']}"
                                                                        itemValue="" />
                                                                    <f:selectItems value="#{listStateNew.allState}" />
                                                                </h:selectOneMenu>
                                                                <h:outputText value="&nbsp" escape="false" />
                                                                <h:outputText value="*" styleClass="formnotes" />
                                                            </h:panelGroup>

function updateDropDown(parent, child, chosen, basicArrayName)
{
    var value;
    var arrayItem;
    var arrayName;
    var instruction;
    if (parent == null) return;
    if (child == null) return;
    value = parent.value;
    arrayName = "";
    arrayName = arrayName + basicArrayName;
    arrayName = arrayName + "_";
    if (value == '')
    {
        //empty array
        arrayItem = new Array();
    }
    else
    {
        arrayName = arrayName + value;
        instruction = "arrayItem = " + arrayName;
        eval(instruction);
    }
    if (chosen == '')
    {
        chosen = child.value;
    }
    loadItem(arrayItem, child, chosen);
}

function loadItem(arrayItem, control, value)
{
    var itemLength;
    var lastItem;
    itemLength = arrayItem.length;

    while (itemLength < control.options.length) {
        lastItem = control.options.length - 1;
        control.options[lastItem] = null;
    }
    control.options[0] = new Option('-', '');
    var foundLocation = 0;
    for (var i = 0; i < itemLength; i++) {
        var opt = eval("new Option" + arrayItem[i]);
        if (opt.value == value) {
            foundLocation = i+1;
        }
        control.options[i+1] = opt;
    }
    control.selectedIndex = foundLocation;
}

Last edited by shabbir; 25Mar2010 at 09:52.. Reason: Code blocks