I have a Combo Box and I would like to have the possibility to add new values in the Combo Box using a button and an Input Field. I tried with:
var value = getCo
Use a viewScope e.g. viewScope.selectItems
variable.
This is a working example:
<xp:comboBox
id="comboBox1"
value="#{sessionScope.test}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
if (!viewScope.selectItems) {
viewScope.selectItems = ["your","initial","values"];
}
return viewScope.selectItems;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
<xp:inputText
id="inputText1"
value="#{viewScope.newItem}">
</xp:inputText>
<xp:button
value="Add to selectItems"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
viewScope.selectItems.add(viewScope.newItem);
viewScope.newItem = "";
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>