JavaScript Not able to remove values from array after uncheck in checkboxes pivot table remove values heading,pivot table remove values less

I have a requirement where all the checked values in checkboxes should be displayed in a textarea. This part works perfectly fine, but the problem occurs when I uncheck the checkbox unchecked element is not getting removed from the array. I have used jquery each function as shown in double quotes.

$("input:checkbox[name=category]:checked").each(function() {

As per my understanding, the above function will check for only checked values and updates into the array, so if any value is unchecked and this function is called, the unchecked value should be removed isn't it?

var pc = [];
function check(){
$("input:checkbox[name=category]:checked").each(function(){
             pc.push(decodeURI($(this).val()));
    });
    	 pc = $.unique(pc);
    document.getElementById("result").value = pc.join("\n");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<body onload ="check()">
<input type="checkbox" name="category" value="a/b" onclick="check()" checked>
<input type="checkbox" name="category" value="c/d" onclick="check()" checked>
<input type="checkbox" name="category" value="e/f" onclick="check()" checked>
<input type="checkbox" name="category" value="g/h" onclick="check()" >

<textarea id="result"></textarea>
Answer:1

it could be helpful to you what I had changed here is the variable creation var pc=[] inside the check()

 
    function check(){
        var pc = [];
        $("input:checkbox[name=category]:checked").each(function(){
                 pc.push(decodeURI($(this).val()));
        });
        pc = $.unique(pc);
        document.getElementById("result").value = pc.join("\n");
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <body onload ="check()">
    <input type="checkbox" name="category" value="a/b" onclick="check()" checked>
    <input type="checkbox" name="category" value="c/d" onclick="check()" checked>
    <input type="checkbox" name="category" value="e/f" onclick="check()" checked>
    <input type="checkbox" name="category" value="g/h" onclick="check()" >

    <textarea id="result"></textarea>
Answer:2

I'm using Reactabular to create a dynamic table. I've looked everywhere in the source code but couldn't find the CSS file which is responsible for controlling the height and width of the columns. Can ...

I'm using Reactabular to create a dynamic table. I've looked everywhere in the source code but couldn't find the CSS file which is responsible for controlling the height and width of the columns. Can ...

  1. react table change width
  2. react table change column width
  3. react bootstrap table change column width

Am trying to find a better way to return a range of array values from an existing array. For an list/array of numbers, say: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] I want to select a range of 5 numbers ...

Am trying to find a better way to return a range of array values from an existing array. For an list/array of numbers, say: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] I want to select a range of 5 numbers ...

  1. find subset of array
  2. find subset of array with given sum
  3. find subset of array in java
  4. find subset of array in c
  5. find subset of array python
  6. find subset sum array
  7. find subset of array matlab
  8. finding max sum array subset
  9. finding index of the subset array

I am using React for this project. I need to read the state directly after I set it (using the callback), but when I print the state to the screen using the callback I get the values of the previous ...

I am using React for this project. I need to read the state directly after I set it (using the callback), but when I print the state to the screen using the callback I get the values of the previous ...

  1. react setstate callback example
  2. react setstate callback hooks
  3. react setstate callback arguments
  4. react setstate callback function
  5. react setstate callback async
  6. react setstate callback not called
  7. react setstate callback vs object
  8. react setstate callback state not updated
  9. react setstate callback prevstate
  10. react setstate callback before render
  11. react setstate callback previous state
  12. react setstate callback return
  13. react setstate callback doesn't work
  14. react setstate callback typescript
  15. react setstate callback functional component
  16. react setstate callback delay
  17. react setstate callback new state
  18. react setstate callback another setstate
  19. react setstate callback parameters
  20. react setstate callback called twice

I am working with React using Webpack and I am having trouble getting static images to load. The loader seems to be correctly converting the image to a URL but it doesn't seem to work as the img src ...

I am working with React using Webpack and I am having trouble getting static images to load. The loader seems to be correctly converting the image to a URL but it doesn't seem to work as the img src ...

  1. static images with movement
  2. static images with quotes
  3. static images in django
  4. static images in react
  5. static images in spring boot
  6. static images in flask
  7. static images in laravel
  8. static images in html
  9. static images in reactjs
  10. static images in java
  11. static images of