How to dynamically change the display value of the selected option in a select box variable

suvro
Mega Sage
Mega Sage

Hi,

 

I have created a select box variable, where I am creating the options dynamically using g_form.addOption(), which is working fine.

 

Below are some sample options

1. label : 12345  Bank of India, value : 12345, displayValue: 12345  Bank of India

2. label:  67891 State Bank of India, value: 67891, displayValue: 67891 State Bank of India

 

After I select any of the above options, I want to change the label of the selected option equal to value.

 

Because I want to show the users the number and the bank name while selecting but after selection I want the variable to show only the number.

 

IS that possible??

 

 

 

 

10 REPLIES 10

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @suvro ,

 

Why change field lable ? why dont you make use of showFieldMessage(); to show both bank and code based on selection.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi Sohail,

While selecting I want to show the bank name but after selection I only want to show them the code.

Yes you can do a client script using gs.showFieldMessage(),

 

Once the bank is selected use the newValue + the bankcode to be show in the field message.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

yad_achyut
Giga Guru

Hello @suvro ,

It seems you need a different value in the background after the from is submitted than the selection at the time of submitting the form.
First you need to understand the Syntax of the g_form.addOtion() as 

g_form.addOption(String fieldName, String choiceValue, String choiceLabel) 
using this you can place your values as follows and it will get you the desired result.

you can try as : 

 

 

g_form.addOption('field_name', '12345', '12345  Bank of India') ; 

 

 


in place of the value you can pass your dynamic variables.

Regards
Achyut