How do you hide a radio button option?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2015 08:27 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 02:08 PM
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;
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 02:29 PM
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.