getValue() is returning label of a choice instead of Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:31 PM
Hi all,
I want to get the value of a choice of a field.
Field Label: Month
Field ID: month
Field Type: Choice
var month = g_form.getValue('month');
g_form.addInfoMessage(month);
By this I am getting the 'January', but I need the value of January i.e., '1'.
How to achieve this?
Thanks,
Yesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:35 PM
Hi Yesh,
is your backend value is 1 for January in choice ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:37 PM
Hi Chetan,
Yes, The backend Value of January is 1 in choice.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:03 AM
Hi Yesh,
Not sure but can you please try below one
var choiceValue = g_form.getValue(<fieldName>);
var choice = g_form.getOption(<fieldName>, choiceValue).value;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:08 AM
Hi Chetan,
The script you have given not returning any value. It is returning ([object HTMLOptionElement]) this in info message.
Regards,
Yesh