reactjs radio button onchange
class App extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
handleChange = e => {
const { name, value } = e.target;
this.setState({
[name]: value
});
};
render() {
return (
<div className="radio-buttons">
Windows
<input
id="windows"
value="windows"
name="platform"
type="radio"
onChange={this.handleChange}
/>
Mac
<input
id="mac"
value="mac"
name="platform"
type="radio"
onChange={this.handleChange}
/>
Linux
<input
id="linux"
value="linux"
name="platform"
type="radio"
onChange={this.handleChange}
/>
</div>
);
}
}var SearchResult = React.createClass({
getInitialState: function () {
return {
site: '',
address: ''
};
},
onSiteChanged: function (e) {
this.setState({
site: e.currentTarget.value
});
},
onAddressChanged: function (e) {
this.setState({
address: e.currentTarget.value
});
},
render: function(){
var resultRows = this.props.data.map(function(result){
return (
<tbody>
<tr>
<td><input type="radio" name="site_name"
value={result.SITE_NAME}
checked={this.state.site === result.SITE_NAME}
onChange={this.onSiteChanged} />{result.SITE_NAME}</td>
<td><input type="radio" name="address"
value={result.ADDRESS}
checked={this.state.address === result.ADDRESS}
onChange={this.onAddressChanged} />{result.ADDRESS}</td>
</tr>
</tbody>
);
}, this);
return (
<table className="table">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
</thead>
{resultRows}
<tfoot>
<tr>
<td>chosen site name {this.state.site} </td>
<td>chosen address {this.state.address} </td>
</tr>
</tfoot>
</table>
);
}
});
Also in JavaScript:
- javascript replace array element
- display none after hover
- new line in javascript alert
- jquery validator driving license
- define value in js
- vue test utils call component method
- bootstrap show modal on page load
- ERROR in ./node_modules/tns-core-modules/ui/core/view/view.js Module not found: Error: Can't resolve '@nativescript/core/ui/core/view/view' in '/home/deepali/projects/supersquad-client/node_modules/tns-core-modules/ui/core/view'
- html button click only once
- javascript append to json
- angular run behind proxy
- javascript tap and hold
- javascript training
- how to read json file in C#
- parsefloat jquery
- how to calculate the number of days between two dates in javascript
- moment.js
- stackoverflow narrate text js
- jquery select input value empty and hasclass
- check server command discord.js
- image slideshow in jquery
- get syntethicbaseevent and parameter in react
- javascript months array
- javascript get list of class names