Skip to content

Instantly share code, notes, and snippets.

@shicky
Last active June 16, 2016 10:34
Show Gist options
  • Save shicky/6a34c7637556dde6016f7bfe194aac21 to your computer and use it in GitHub Desktop.
Save shicky/6a34c7637556dde6016f7bfe194aac21 to your computer and use it in GitHub Desktop.
Handling checkbox
const Form = require('react-bootstrap/lib/Form');
const FormGroup = require('react-bootstrap/lib/FormGroup');
const FormControl = require('react-bootstrap/lib/FormControl');
const Col = require('react-bootstrap/lib/Col');
const ControlLabel = require('react-bootstrap/lib/ControlLabel');
onChangeValue(evt, check=false) {
this.setState({[evt.target.id]: check?evt.target.checked:evt.target.value});
},
return (
<Form>
<FormGroup controlId="name">
<Col componentClass={ControlLabel} sm={2}>
Name
</Col>
<Col sm={10}>
<FormControl type="text" placeholder="Enter Name" value={this.state.name} onChange={this.onChangeValue} />
</Col>
</FormGroup>
<FormGroup controlId="enabled">
<Col componentClass={ControlLabel} sm={2}>
Enabled
</Col>
<Col sm={10}>
<FormControl type="checkbox" placeholder="Enter Comma-Separated Numbers" value={this.state.port_scan} onChange={this.onChangeValue} />
</Col>
</FormGroup>
</Form>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment