This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jan 18, 2012, 3:25 PM
66 Posts
topic has been resolvedResolved

Get Label Value of Combo Box in SSJS

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 2
In a combo box with a Label | Value pair, I need to get the Label value of the selected choice. I don't want a list of all the choices. I know there is .getItemLabel() and .getLabel() but these methods don't work on getComponent("comboBox1").getLabel() or getComponent('comboBox1").getItemLabel()
 
Does anyone know a way to get this label value? Thanks for any help.
Jan 19, 2012, 1:10 PM
272 Posts
Re: Get Label Value of Combo Box in SSJS
Hi,
 
you could use this function to get the selected label (id is the component id of the combo box):
 
function getSelectedLabel( id ) {
   var ComboBox = getComponent( id );
   var value = ComboBox.value;
  
   var ChildrenList:java.util.ListIterator;
   ChildrenList = ComboBox.getChildren().listIterator();
   while (ChildrenList.hasNext()) {
      var Child = ChildrenList.next();
    
      /*** process computed / multiple values ***/
      if( typeof( Child ) == 'com.ibm.xsp.component.UISelectItemsEx' ){
         var hlp = Child.getValue();
         for( var i=0; i< hlp.length; i++ ){
             if( hlp[i].getValue() == value )
             return hlp[i].getLabel() ;
         }
      }
 
      /*** process single values ***/
      if( typeof( Child ) == 'com.ibm.xsp.component.UISelectItemEx' ){

      if( Child.getItemValue() == value )
          return Child.getItemLabel();
      }
   }
}

 
Hope this helps
Sven
 
Jan 19, 2012, 1:19 PM
66 Posts
Re: Get Label Value of Combo Box in SSJS
 Thanks Sven! This is exactly what I was looking for.

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal