0
$("#selUser").bind('change keyup', function() {
    $('#selSubjects2').empty();


    if($(this).val().length > 0)
      $.each( $(this).val().split(','), function(i, val) {
        var option = new Option(val, val);
        option.selected = true;
        console.log("option",option);
        $('#selSubjects2').append(option);
      });

    $('#selSubjects2').trigger("change");
  });

enter image description here

I am trying to remove the options from selsubjects2 using the empty method. When selecting a new user from the SelUser dropdown, I want to clear all the options in selSubjects2 using the empty method.

Currently, after selecting permissions for User1, if I choose permissions for User2, it appends these new permissions to the existing options of User1. The goal is to entirely remove User1's permissions and then populate selSubjects2 with User2's permissions. This ensures that only the permissions of the currently selected user are displayed, removing the previous user's permissions entirely. enter image description here

How do I get rid of user1's permissions completely and then append the user'2 permissions?

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.