3.2.0

Set Selected In AW.UI.Combo

I am using a "standalone" AW.UI.Combo().

Assuming I know which item I want to default the combo to, how does one do that? Here's a snippet of the ASP code I am using and which doesn't work. The combo remains blank. setSelectedItems([<%=po_num%>]) doesn't seem to set the combo to a specific item. (po_num, obviously, would be the variable that contains the index to have as selected.)

Help?

var postalCombo = new AW.UI.Combo();
postalCombo.setId("postalCombo");
postalCombo.setItemCount(myPOVals.length);
postalCombo.setItemText(myPOVals);
postalCombo.setItemValue(myPOKeys);
<% If po_def > 0 Then %>
postalCombo.setSelectedItems([<%=po_num%>]);
<% End If %>
// make combo more <select>-like
postalCombo.getContent("box/text").setAttribute("readonly", true); 
postalCombo.onControlEditStarted = function() {
    this.getContent("box/text").element().contentEditable = false;
}
postalCombo.onControlValidated = function(){
    alert(this.getSelectedItems()); 
    alert(this.getItemValue(this.getSelectedItems())); 
}
document.write(postalCombo);
Paul Tiseo
June 30,
Answering myself after having looked at:
http://www.activewidgets.com/javascript.forum.14970.3/stupid-question.html

In the above example, I set the key, but not the displayed value. Use the additional line:

<% If po_def > 0 Then %> 
postalCombo.setSelectedItems([<%=po_num%>]);
postalCombo.setControlText(myPOVals[<%=po_num%>]); 
<% End If %>
Paul Tiseo
July 5,

This topic is archived.

See also:


Back to support forum