As in the title of the question, I cannot mark the checkbox as selected in the onChange event of this selectbox, for example,
<select id='featuresType' onChange={this.handleChange.bind(this, 'type')} > {this.getOptions(featuresType)} </select>
were like handleChange:
handleChange: function (field, e) { if (field == 'type') { let selected = e.target.value; this.setState({typeSelected: selected}) } console.log(field ,',', this.state.typeSelected) },
when it binds to defaultValue,
defaultChecked={(this.state.typeSelected =='locker')}
- The selection field cannot indicate the specified condition, but manually checked / notchecked can be checked.
checked={(this.state.typeSelected =='locker')}
- In this checked attribute, the flag can be marked as checked, based on the value of the selection box option. BUT in this case, a manual verification method or verification does not occur.
Hope you guys had a problem.
Here is the JSFiddle
I wanted the flag to work in both directions, when choosing the option, the flag should be checked. And also the user can check / uncheck Manully
source share