1
votes

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

3

3 Answers

0
votes

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?

0
votes

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

0
votes

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" />