取消选中复选框

时间:2018-08-22 10:20:11

标签: javascript html arrays reactjs checkbox

在取消选中Checkbox元素时,应该将其从数组中删除吗?

     {
           columns.columnNames && columns.columnNames.map(el => {  
             return (
                <div>
                   <input type="checkbox" value={el}  onChange={this.select_MS.bind(this)} /> {el}
                 </div>
                    )
               })
      }

OnChange 事件如下所示:

    select_MS(event) {

        var permissions = this.state.permissions;
        if (event.target.checked) {
            permissions.push(
                event.target.value

            )
        }


        this.setState({permissions: permissions});

检查3个元素后,数组如下所示:      } enter image description here

取消选中数组中的元素后,它仍然显示 enter image description here

1 个答案:

答案 0 :(得分:2)

取消选中时,不会将其从阵列中删除。

TestPointToInputMask tpm2 =
    (from m in ent.InputMask
     join tm in ent.TestPointToInputMask on m.inputMaskId equals tm.inputMaskId
     join tp in ent.TestPoint on tm.testPointId equals tp.testPointId
     join tc in ent.TestPointToChapter on tp.testPointId equals tc.testPointId
     join c in ent.Chapter on tc.chapterId equals c.chapterId
     join dc in ent.Description on c.textKey equals dc.textKey
     join dp in ent.Description on tp.textKey equals dp.textKey
     where m.inputMaskName.ToUpper() == inputMaskName.ToUpper()
     && tp.testPointNumber.ToUpper() == testPointNumber.ToUpper()
     && dc.text.ToUpper() == chapterText.ToUpper()
     && c.testTypeId == testTypeId
     && dc.languageId == 1
     && dp.languageId == 1 && dp.text.StartsWith(testPointText)
     select tm).FirstOrDefault();
相关问题