getOption always return null

bourhoud
Kilo Expert

Hi all,

I have a problem for getting value of a choice list, in a client script.

In a form, I have a field, type choice, with any specified choices. Its name is u_quotation_type.

In a client script, I try to get dynamically the display value of an option.

For this, I'm trying to use g_form.getOption, and then get its innerText property.

And there, is the problem : my getOption always return null..

Below my (simple) code :

alert( g_form.getValue('u_quotation_type'));     // Displays "option"

alert(g_form.getOption("u_quotation_type", 'option')); // Displays null

alert(g_form.getOption("u_quotation_type", 'Option')); // Displays null

alert(g_form.getOption("u_quotation_type", g_form.getValue('u_quotation_type'))); // Displays null

I'm working on a Helsinki instance.

Can anyone give me help, please ?

18 REPLIES 18

Hi blaze,



Thanks. That's what I did, but I'm getting "null" value.



My lines of code try different cases, but still "null" as answer


hi pierre,


                        everything is lower case. and as i mentioned cpu can be a word or it can be a number you have to check the value of the field in the choices list. I tested it in helsinki and it works for helsinki.



Thank you


Thanks for your help.



I agree with you, and that's what I did :


alert(g_form.getOption("u_quotation_type", g_form.getValue('u_quotation_type'))); // this line should work, because it uses directly the value by getValue...


Now i get what you want to do so try this


var a = g_form.getValue('subcategory');


      alert(a);



this should solve your issue.



Thank you


please mark correct/helpful if applicable.


Sorry, but it seems you haven't understood :



the goal is to get a display value of an option, in a choice list.


That's why I use the getOption method, to call text property then.



My problem is that the getOption itself sends back "null", as if it doesn't find my option ...




(Sorry if I'm not understandable =/)