How do you hide a radio button option?

e_wilber
Tera Guru

How would you go about removing/adding the options from a radio button variable so you can show/hide them dynamically? I tried g_form.disableOption() but that is just for select boxes. How do we do the same functionality for multiple choice variables?

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

please use below sample code to hide radio button option

 

//This assumes that your variable is named "safe_request_type" and your option value is "architecture"


function onLoad() {


     if (!g_user.hasRole("itil")){


           showRadio("safe_request_type","architecture",false);


     }


     function showRadio(strVarName, strOption, bVisible){


           var myOptions = g_form.getControl(strVarName).up(1).getElementsByTagName("label");


           for (var i=0;i<myOptions.length;i++){


                 var element = myOptions[i].getElementsByTagName("input")[0];


                 if (element.value == strOption){


                       element.hidden=!bVisible;


                       myOptions[i].hidden=!bVisible;


                       break;     


                 }


           }


     }


}

SanjivMeher
Kilo Patron
Kilo Patron

There is no option to do that and I wouldn't do any DOM manipulation, since it wont work in Service Portal. Instead I would go for a Select Box and use g_form.removeOption() to remove an option


Please mark this response as correct or helpful if it assisted you with your question.