Need to hide choice list on the field which is under section

harinya
Tera Contributor

function onload(){

var value=g_form.getValue('connect');

if(value=='6')//6 is the backend value of my connect choice

{

g_form.removeOption('result', '4');

}

else{

g_form.addOption('result', '4', 'confirmed');

}
but this code is not working can some one help on this , 
result filed is in form section as like below image

harinya_0-1742399188559.png

 


Thanks in advance

10 REPLIES 10

harinya
Tera Contributor

but i can see choices are available for that field

harinya
Tera Contributor

harinya_0-1742401588428.png

it's already there

Okay,  what is the value coming for the variable - 'value' here -

var value=g_form.getValue('connect');

can you alert that variable?

harinya
Tera Contributor

yes, it is giving the expected value

Medi C
Giga Sage

@harinya,

 

Please create the option first on your field and you after that you can just hide the option as per your requirements:

var value=g_form.getValue('connect');    
if (value == 6) {
        g_form.removeOption('result', '4');
}

What you should also check, the script is running when the form loads. Which means, the fields "connect" and "result" you are working with should be visible when the form loads for this to work. (Check if any of these fields is visible only under other circumstances)


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.