cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Workflow Hero

Clear the managed metadata control using JavaScript

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.

Labels: (1)
Reply
3 Replies
Workflow Hero

Re: Clear the managed metadata control using JavaScript

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('');
     }

   });
});

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Clear the managed metadata control using JavaScript

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.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Clear the managed metadata control using JavaScript

Hi Ritesh,

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

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

Thanks,

Soni

0 Kudos
Accept as Solution Reply