How to hide radio button option.

Meenal Gharat
Giga Guru

Hi All,

How can we hide radio button option on the basis of users country code.

I tried using g_form.removeOption() but it doesn't worked.

What do we use to hide Radio Button option in client script?

Note : Also tried using -

 if(result == 'US')
{
//g_form.removeOption('phone','Iphone 7','iphone');
var radiobtn = document.getElementsByName("myid");
//radiobtn.checked = true;

radiobtn.style.visibility="hidden";
radiobtn.style.display="none";

 

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

I wouldn't use DOM manipulation for this. You could do a select box and use g_form.removeOption().

Please mark this as correct/helpful if this resolved your issue!

View solution in original post

6 REPLIES 6

Rahul Kathuria
Tera Expert

Hi Meenal,

 

This onload script will do the job. 

 

//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;    

 

                }

 

          }

Hi Rahul,

Thanks for replying.

Will try on above and let you know accordingly.

 

Thanks and Regards,

Meenal