The onChanging Event

Since a combobox is also a text box, the onChanging event will be sent if you add a listener for it. By listening to this event, you could manipulate the drop-down list as the Google Suggests[41] does. This feature is sometimes called autocomplete.

As illustrated below, you could fill the drop-down list based on what user is entering.

<combobox id="combo" autodrop="true" onChanging="suggest()"/>
<zscript>
    void suggest() {    
        combo.getItems().clear();        
        if (event.value.startsWith("A")) {        
            combo.appendItem("Ace");            
            combo.appendItem("Ajax");            
            combo.appendItem("Apple");            
        } else if (event.value.startsWith("B")) {        
            combo.appendItem("Best");            
            combo.appendItem("Blog");            
        }        
    }    
</zscript>

Notice that, when the onChanging event is received, the content of the combobox is not changed yet. Thus, you cannot use the value property of the combobox. Rather, you shall use the value property of the event (org.zkoss.zk.ui.event.InputEvent).



[41] http://www.google.com/webhp?complete=1&hl=en