Skip to main content

I have a Managed Metadata Control that I want to clear whenever a checkbox is unchecked.

Managed Metadata control

Client ID JavaScript variable name for the checkbox is 'fldCheckBox'

Client ID JavaScript variable name for the Managed Metadata control is 'fldMetaData'

I am using the following code -

 NWF$(document).ready(function()
{  

      NWF$('#'+ fldCheckBox).change(function()
     {
          if(NWF$('#' + fldCheckBox).prop('checked') == false)
          {
               NWF$('#' + fldMetaData).val('');
          }
     });   

});

I am able to get into the change event and into the if block as well.

 

However the following statement is not making the desired effect.

NWF$('#' + fldMetaData).val('');

Could somebody please help me with a JavaScript to clear this metadata control, whenever the checkbox is unchecked.

I would appreciate any help extended to me.

Thanks.

It should work. Try below code (instead 'Change', try with 'Click' event).

NWF$(document).ready(function()
{  

   NWF$('#' + fldCheckBox).click(function()
   {
     var checkBox = NWF$('#' + fldCheckBox);
     if (checkBox.is(':checked') == false)

     {

       NWF$('#' + fldMetaData).val('');
     }

   });
});


Hi Lakshmi,

It did not work.

The problem is not with the change event. I am able to get into the change event and into the if block as well.

The problem is that the statement " NWF$('#' + fldMetaData).val('');" is not making the desired effect.

Thanks.


Hi Ritesh,

Try using NWF$('#' + fldMetaData).text('');

In one of my environment this helped in updating the metadata field.

Thanks,

Soni


Reply