3.2.0

Setting An AW.UI.Combo's Value


So, I instantiate a combo box using:

var versionCombo = new AW.UI.HTMLStripCombo();
versionCombo.setId("versionCombo");
versionCombo.setItemCount(vers_val.length);
versionCombo.setItemText(vers_val);
[b]versionCombo.setSelectedItems(1);[/b]
document.write(versionCombo);


How does one set the combo to a value in the array of values, in this case vers_val[]?

The line in bold is incorrect, since it seems to do nothing. Using setControlText() just sets the displayed text and not the control's value.

- alphadog
Paul Tiseo
November 21,
My bad. I guess nested styling tags don't work in this discussion forum.
Paul Tiseo
November 21,
Just use an aditional setItemValue(array)
Posted by Javier on Thursday, March 9, 2006
http://www.activewidgets.com/javascript.forum.12308.8/v2-0-combo-control-value.html

And in your case could be resumed as follows:

set values
versionCombo.setItemValue(["id", "name", "date"]);
set Texts
versionCombo.setItemText(["Number", "Account", "Operation Date"]);
set Selection:
versionCombo.setSelectedItems([1]); /// note the brackets
and to know the selected value, use
var selected_value = versionCombo.getItemValue(versionCombo.getSelectedItems());
Carlos
November 21,

Carlos, thanks, but it's not working. I'm using:

versionCombo.setSelectedItems([1]);


and the combo's text box remains empty. No error, though. And the value is in fact set, just not displayed. IOW, the call to getItemValue() returns the right option from the drop-down, but the display hasn't been adjusted.

- alphadog
Paul Tiseo
November 22,

Don't know if there is a better way, but here's one option:

versionCombo.setControlText(versionCombo.getItemText(versionCombo.getSelectedItems()));
Paul Tiseo
November 22,
Forgot to add, the call to setControlText() should come after the call to setSelectedItems(), for obvious reasons.
Paul Tiseo
November 22,

This topic is archived.

See also:


Back to support forum