Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

multiple checkbox react

<input
  onChange={(e) => {
    // add to list
    if (e.target.checked) {
      setPeopleInfo([
        ...peopleInfo,
        {
          id: item.id,
          first: item.name,
          last: item.lastName,
          age: item.age,
        },
      ]);
    } else {
      // remove from list
      setPeopleInfo(
        peopleInfo.filter((people) => people.id !== item.id),
      );
    }
  }}
  value={peopleInfo}
  style={{ margin: '20px' }}
  type="checkbox"
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: what is undefined 
Javascript :: javascript turn negative number to positibve 
Javascript :: check if div contains background image 
Javascript :: map keys to list node js 
Javascript :: await and catch javascript 
Javascript :: mongodb replace document 
Javascript :: for loop java script 
Javascript :: setProps jest 
Javascript :: js library for unique id uniqid 
Javascript :: insert array as string google app scripts 
Javascript :: prevent click on pseudo element javascript 
Javascript :: react currency format method 
Javascript :: dummy data json 
Javascript :: how to convert a number to a string in javascript 
Javascript :: break in if statement js 
Javascript :: browser tab switch event js 
Javascript :: javascript while loop 
Javascript :: javascript for loop[ 
Javascript :: tinymce get plain text 
Javascript :: saving react code messing up in vsc 
Javascript :: passport js local strategy response handling 
Javascript :: regex not js 
Javascript :: Round Decimals to a Certain Number of Decimal Places 
Javascript :: react chart.js 
Javascript :: signed and unsigned integers in JavaScript 
Javascript :: how to use the foreach method in javascript 
Javascript :: detect form input changes javascript 
Javascript :: mail 
Javascript :: print an object in javascript 
Javascript :: javascript basic function 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =