Florin Pop
Florin Pop

Reputation: 5135

XPages get Value selected from combo box

I want to display the selected value from the comboBox into a label.

<xp:label id="label4">

    <xp:this.value><![CDATA[#{javascript:var componenta = Contr.getItemValueString("txt_tipcontractcv");

if (componenta == "")
{ return "void";}

if (componenta !="")
{ return "My value is "+componenta}}]]></xp:this.value>
</xp:label>

The label is on a panel, and I did a partial refresh to the respective panel. My comboBox is binded to a data element.

label4 is always void. Why? Thank you,

Florin

Upvotes: 1

Views: 2434

Answers (3)

Gobinath S
Gobinath S

Reputation: 46

The reason is the value selected is not sent to the server. Could you give us the code for combobox, and panel with label. It will give us clear idea for the cause

  1. Are you using partial execution mode?
  2. Is combo box bind to data source value="Contr.txt_tipcontractcv"?

You may also code the label as below, if that suits

<xp:label id="label4" value="Contr.txt_tipcontractcv" />

Upvotes: 0

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

Try Contr.getValue("txt_tipcontractcv") (assuming that Contr is your datasource).

Upvotes: 0

Florin Pop
Florin Pop

Reputation: 5135

I changed code into:

var componenta = getComponent("combo").getValue();

if ((componenta == null) || (null == componenta))
{ return "void";}

else if ((componenta != null) || (null != componenta))
{ return "My value is "+componenta}  

and now it returns : My value is It seems that componenta is an empty string. Why?

Upvotes: 0

Related Questions