I'm new in react Js and i wanna set disable some of element according to the conditions
I have three element in my form one select and two input
according to selected item one of input must be disable
this is my component code:
class AddUser extends React.Component {
constructor(props) {
super(props);
this.state = {
user: {
}
};
}
render() {
if (this.props.user) {
this.state.user= this.props.user;
}
return (
<div className="form-group">
<label className="control-label">type<span className="symbol required"></span></label>
<select className="form-control" name="CompanyMeetingType" value={this.state.user.type>
<option value="1"> type1</option>
<option value="2">type2</option>
<option value="3">both</option>
</select>
</div>
<div className="form-group">
<label className="control-label">type1(%)<span className="symbol required"></span></label>
<input required type="text" name="type1" className="form-control" disabled={this.state.user.type ==2} />
</div>
<div className="form-group">
<label className="control-label">type1(%)<span className="symbol required"></span></label>
<input required type="text" name="type2" className="form-control" disabled={this.state.user.type ==1} />
</div>
)
}
when I'm changing the selected item disable work correctly but when I'm filing select element in edit mode disable not work