React - onChange events

0 votes
41 views
added Dec 6, 2021 in React by lcjr First Warrant Officer (9,190 points)
constructor(props) {
    super(props);
    this.state = {
      key: 1,
      project: '',
      buildingtypeselect: '',
      buildingtypesdata: [],
      tenure: '',
      lotsize: '',
      poInfo: '',
    }; 
    this.handleCategoryChange = this.handleCategoryChange.bind(this);
  }
  
handleCategoryChange = event => {
  const categoryURL = `/location-scan?category=${event.target.value}`
  Router.push(categoryURL);
  this.setState({
    category: event.target.value,
  });
};
  
<div className="col-3">
  <select
    value={category}
    onChange={this.handleCategoryChange}
    className="form-control table-row custom-select"
  >
    <option value="RESIDENTIAL">RESIDENTIAL</option>
    <option value="COMMERCIAL">COMMERCIAL</option>
    <option value="INDUSTRIAL">INDUSTRIAL</option>
  </select>
</div>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...