I have an react js form.I would like to know how to enable/disable all form input control based on condition.please check my below code and advise how to do this...
return (
<form id ="frm" onSubmit={this.onSubmitHandler}>
<div className="animated fadeIn">
<div className="form-group row">
<Button type="button" text="Back" size="sm" onClick={this.onBackButtonClick} color="danger" className="pull-right ml-1 "><i className="fa fa-ban"></i> Back</Button>
<Button type="submit" size="sm" color="success" className="pull-right ml-1 "><i className="fa fa-dot-circle-o"></i> Save</Button>
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" placeholder="First Name" value={this.state.FirstName} required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName" placeholder="Last Name" value={this.state.LastName} required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3">
<input type="email" name ="EmailId" className="form-control form-control-sm" id="TxtEmailId" placeholder="EmailId" value={this.state.EmailId} required onChange={this.onChangeHandler}/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3">
<input type="text" name ="MobileNo" className="form-control form-control-sm" id="TxtMobileNo" placeholder="Mobile No" value={this.state.MobileNo} onChange={this.onChangeHandler} />
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3">
<select name ="DivisionId" className="form-control" required value={this.state.DivisionId} onChange={this.onChangeHandler}>
{DivisionList}
</select>
</div>
/div>
</form>
);
ComponentDidMount Event to check condition :-
componentDidMount() {
if (this.props.match.params.mode=="Edit"){
// enable form control
}
else
{
// disable form control
}
create a state isFormDisabled for ex.
use html fieldset inside the form and use disabled property and provide the value of isFormDisabled
use your logic to enable/disable based on your needs
Code Sample
...
state = {
isFormDisabled: false
}
componentDidMount(){
if (this.props.match.params.mode == "Edit") {
this.setState({isFormDisabled: false})
}
else {
this.setState({isFormDisabled: true})
}
}
...
//inside render fun...
return (
<form id ="frm" onSubmit={this.onSubmitHandler}>
<fieldset disabled={isFormDisabled}>
<div className="animated fadeIn">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" placeholder="First Name" value={this.state.FirstName} required onChange={this.onChangeHandler}/>
</div>
...
</fieldset>
...
Related
I am using the class component here Consider selecting Yes or No value depending on whether to show or hide the div.
I wanted to do the same thing with multiple div. But here if I am selecting yes then both the div are open. And not close to clicked on no value.
Here is my code:
class PersonalInfo extends Component {
constructor(props) {
super(props);
this.divstatus1 = this.divstatus1.bind(this);
this.divstatus2 = this.divstatus2.bind(this);
this.state = {
value1: 'no',
value2: 'no'
};
}
divstatus1 = (e) => {
this.setState({ value1: e.target.value1 });
}
divstatus2 = (e) => {
this.setState({ value2: e.target.value2 });
}
render() {
return (
<div>
<h3 className="showbase_header">Passport Details</h3>
<div className="form-group">
<label htmlFor="orderby"> Do you have passport ?</label>
<select className="form-control orderby" onChange={this.divstatus1}>
<option value="" selected>Select</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br></br>
<div className={this.state.value1} >
<div className="row">
<div className="col-md-6 form-group">
<label htmlFor="name">Passport Number
<span className="required">*</span>
</label>
<input type="text" id="firstname" aria-required="true" size={30} name="firstname" className="form-control" placeholder="" />
</div>
<div className="col-md-6 form-group">
<label htmlFor="name">Place Of Issue
<span className="required">*</span>
</label>
<input type="text" id="lastname" aria-required="true" size={30} name="lastname" className="form-control" placeholder="" />
</div>
</div>
<div className="row">
<div className="col-sm-6 form-group">
<label htmlFor="expirydate">Expiry Date
<span className="required">*</span>
</label>
<input type="date" id="expirydate" aria-required="true" size={30} name="expirydate" className="form-control" placeholder="" />
</div>
<div className="col-sm-6 form-group">
<label htmlFor="issuedate">Issue Date
<span className="required">*</span>
</label>
<input type="date" id="issuedate" aria-required="true" size={30} name="issuedate" className="form-control" placeholder="" />
</div>
</div>
</div>
</div>
<div className="form-group">
<h3 className="showbase_header">Representation</h3>
<select className="form-control orderby" onChange={this.divstatus2}>
<option value="">Select</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select><br />
<div className={this.state.value2} >
<div class="row">
<div className="col-sm-6 form-group">
<label htmlFor="name">Name
<span className="required">*</span>
</label>
<input type="text" id="name" aria-required="true" size={30} name="name" className="form-control" placeholder="" />
</div>
<div className="col-sm-6 form-group">
<label htmlFor="number">Contact Number
<span className="required">*</span>
</label>
<input type="number" id="name" aria-required="true" size={30} name="number" className="form-control" placeholder="" />
</div>
</div>
</div>
</div>
</div>
);
}
}
export default PersonalInfo;
I have added in main.css
.yes{display: block;}
.no{display: none;}
Can you try this,
divstatus1 = (e) => {
this.setState({ value1: e.target.value });
}
divstatus2 = (e) => {
this.setState({ value2: e.target.value });
}
option does not have an attribute called value1 or value2
I have an bootstrap form with 9 input field.I have applied 3 field in each row which looks as responsive.I would like to know how to add image field on right side and which should be span of three row.please check my below code and advise how to align the image control as right side.
updated code version 3.0.0:-
<div className="container-fluid">
<div className="row">
<div className="col-sm-10">
<div className="container-fluid">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName"
placeholder="First Name" value={ this.state.FirstName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName"
placeholder="Last Name" value={ this.state.LastName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3 pl-0">
<input type="email" name="EmailId" className="form-control form-control-sm" id="TxtEmailId"
placeholder="EmailId" value={ this.state.EmailId } required onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3 pl-0">
<input type="text" name="MobileNo" className="form-control form-control-sm" id="TxtMobileNo"
placeholder="Mobile No" value={ this.state.MobileNo } onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3 pl-0">
<select name="DivisionId" className="form-control" required value={ this.state.DivisionId }
onChange={ this.onChangeHandler }>
{ DivisionList }
</select>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">User Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="UserName" className="form-control form-control-sm" id="TxtUserName"
placeholder="User Name" value={ this.state.UserName } required
onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Password</label>
<div className="col-sm-3 pl-0">
<input type="password" name="DPassword" className="form-control form-control-sm" id="TxtPassword"
placeholder="Password" value={ this.state.DPassword } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Confirm</label>
<div className="col-sm-3 pl-0">
<input type="password" name="ConfirmPassword" className="form-control form-control-sm"
id="TxtConfirm" placeholder="Confirm Password" required value={ this.state.ConfirmPassword }
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Role</label>
<div className="col-sm-3 pl-0">
<select name="RoleId" data-show-subtext="true" data-live-search="true"
className="form-control selectpicker" id="CboRole" value={ this.state.RoleId } required
onChange={ this.onChangeHandler }>
{ RoleList }
</select>
</div>
</div>
</div>
</div>
<div className="col-sm-2">
<img className='img-fluid' src={ users } alt='Alt text'/>
</div>
</div>
</div>
screenshot :-
It depends on how many cols do you want your image to take, but what you can do is the following: Wrap your code in a new Row. Then divide it into as many columns as you want (for the example I have divided it 50:50 - 50% of the screen will be filled with your inputs and 50% with the image) - you can configure this by yourself. Try the following and let me know if this is what you seek:
<div className="container-fluid">
<div className="row">
<div className="col-sm-6">
<div className="container-fluid">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName"
placeholder="First Name" value={ this.state.FirstName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName"
placeholder="Last Name" value={ this.state.LastName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3">
<input type="email" name="EmailId" className="form-control form-control-sm" id="TxtEmailId"
placeholder="EmailId" value={ this.state.EmailId } required onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3">
<input type="text" name="MobileNo" className="form-control form-control-sm" id="TxtMobileNo"
placeholder="Mobile No" value={ this.state.MobileNo } onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3">
<select name="DivisionId" className="form-control" required value={ this.state.DivisionId }
onChange={ this.onChangeHandler }>
{ DivisionList }
</select>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">User Name</label>
<div className="col-sm-3">
<input type="text" name="UserName" className="form-control form-control-sm" id="TxtUserName"
placeholder="User Name" value={ this.state.UserName } required
onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Password</label>
<div className="col-sm-3">
<input type="password" name="DPassword" className="form-control form-control-sm" id="TxtPassword"
placeholder="Password" value={ this.state.DPassword } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Confirm</label>
<div className="col-sm-3">
<input type="password" name="ConfirmPassword" className="form-control form-control-sm"
id="TxtConfirm" placeholder="Confirm Password" required value={ this.state.ConfirmPassword }
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Role</label>
<div className="col-sm-3">
<select name="RoleId" data-show-subtext="true" data-live-search="true"
className="form-control selectpicker" id="CboRole" value={ this.state.RoleId } required
onChange={ this.onChangeHandler }>
{ RoleList }
</select>
</div>
</div>
</div>
</div>
<div className="col-sm-6">
<img className='img-fluid' src={ path } alt='Alt text'/>
</div>
</div>
</div>
I have an React form with 10 input field.I have a below code to set state for each field and finally I have submit this state to database.(insert record in table using post method via state).I would like to know how to set value in each in each input field via get method.
initial State :-
this.state = {
UserId : this.props.match.params.id,
FirstName: '',
LastName : '',
EmailId : '',
MobileNo : '',
DivisionId :'',
UserName : '',
Password : '',
ConfirmPassword : '',
RoleId : '',
UpdateUserName : localStorage.getItem("UserId"),
GridState : []
};
Setting State Value in each input Field before submitting :-
onChangeHandler = (event) => {
let nam = event.target.name;
let val = event.target.value;
this.setState({[nam]: val});
}
Submit Record to Database via Post Method :-
onSubmitHandler = (event) => {
axios.post(ConfigItem[0].APIPath+'Users/',this.state)
.then(res => {
this.props.history.push('/UserList')
})
}
Get inserted record from API via get method :-
axios.get(ConfigItem[0].APIPath+'users/' + this.props.match.params.id)
.then(res => {
console.log(res.data.data); ***// I would like to know how to set value in each input field***
HTML render :-
render() {
return (
<form onSubmit={this.onSubmitHandler}>
<div className="animated fadeIn">
<Row>
<Col xs="12" sm="12">
<Card>
<CardHeader>
<Row>
<Col xs="8" sm="8">
<strong> <i> User Creation Entry </i> </strong>
</Col>
<Col xs="4" sm="4">
<Button type="button" text="Back" size="sm" onClick={this.onBackButtonClick} color="danger" className="pull-right ml-1 "><i className="fa fa-ban"></i> Back</Button>
<Button type="submit" size="sm" color="success" className="pull-right ml-1 "><i className="fa fa-dot-circle-o"></i> Save</Button>
</Col>
</Row>
</CardHeader>
<CardBody>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" placeholder="First Name" required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName" placeholder="Last Name" required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3">
<input type="email" name ="EmailId" className="form-control form-control-sm" id="TxtEmailId" placeholder="EmailId" required onChange={this.onChangeHandler}/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3">
<input type="text" name ="MobileNo" className="form-control form-control-sm" id="TxtMobileNo" placeholder="Mobile No" onChange={this.onChangeHandler} />
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3">
<select name ="DivisionId" className="form-control" required onChange={this.onChangeHandler}>
{DivisionList}
</select>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">User Name</label>
<div className="col-sm-3">
<input type="text" name ="UserName" className="form-control form-control-sm" id="TxtUserName" placeholder="User Name" required onChange={this.onChangeHandler}/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Password</label>
<div className="col-sm-3">
<input type="password" name ="Password" className="form-control form-control-sm" id="TxtPassword" placeholder="Password" required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Confirm</label>
<div className="col-sm-3">
<input type="password" name="ConfirmPassword" className="form-control form-control-sm" id="TxtConfirm" placeholder="Confirm Password" required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Role</label>
<div className="col-sm-3">
<select name ="RoleId" data-show-subtext="true" data-live-search="true" className="form-control selectpicker" id="CboRole" required onChange={this.onChangeHandler}>
{RoleList}
</select>
</div>
</div>
</CardBody>
<CardFooter>
<div id="data-grid-demo">
<DataGrid
dataSource={this.state.GridState}
ref={ref => this.dataGrid = ref}
keyExpr="MenuId"
showBorders={true}
onToolbarPreparing={this.onToolbarPreparing}
onRowUpdated={this.onRowUpdated}
>
<Paging enabled={false} />
<Editing
mode="batch"
allowUpdating={true}
selectTextOnEditStart={true}
startEditAction='click' />
<Column dataField="UserAccessId" visible={false} />
<Column dataField="MenuId" visible={false} />
<Column dataField="Menu" />
<Column dataField="SubMenu" />
<Column dataField="ViewAccess" caption="ViewAccess" dataType="boolean" >
<CheckBox defaultValue={false} />
</Column>
<Column dataField="ZohoParameter" />
<Column dataField="Remarks" />
</DataGrid>
</div>
</CardFooter>
</Card>
</Col>
</Row>
</div>
</form>
);
}
Set the value to each <input /> that is equal to the class state, for example:
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" value={this.state.FirstName} placeholder="First Name" required onChange={this.onChangeHandler}/>
After that, simply save your data from the axios call into the state:
this.setState({
FirstName: result.data.FirstName,
//Add the others by yourself
})
If your query result properties have the same name as the ones in your state, you could simply do:
this.setState({
...result.data.data //depending on your result object structure
})
the second statement is not working,please check my below result of json data and advise how to do this..
[{"UserId":2009,"FirstName":"jj","LastName":"kk","EmailId":"kk.biz#itytu.com","MobileNo":"9789684772","DivisionId":4,"UserName":"khizer11","Password":"$2b$10$JRG/Zp5TQOJkZPIj2bXFset3gx8DF/OFnrGzZqR4rnC7Bc/a9.yyO","DPassword":"ii#123","RoleId":8,"LoginTag":null,"LoginTime":null,"LogOutTime":null,"SysName":"DELLNETBOOK","UpdateUserName":"","UpdateSysName":null,"UpdateDateTime":null,"DefaultDateTime":
I am creating a form which has 23 input fields. In this form, i am not able to add any data through all fields are copy pasted.Few fields are editable I can enter any data while few fields are not editable I can see cursor but I cannot enter any data. Fields beneath long-term liablity are editable while above fields are not editable
<form onSubmit={this.handleSubmitFirebase}>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounting period</label>
<input type="date" className="form-control" ref={el => this.billto = el} onChange={this.handleChange} />
<input type="date" className="form-control" ref={el => this.billfrom = el} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">WORKING CAPITAL</label>
<input type="text" className="form-control" ref={el => this.state.capital = el} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">CURRENT ASSETS</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Cash</label>
<input type="text" className="form-control" value={this.state.cash} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Investments</label>
<input type="text" className="form-control" value={this.state.investments} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Inventories</label>
<input type="text" className="form-control" value={this.state.inventories} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts receivable</label>
<input type="text" className="form-control" value={this.state.ac_receiv} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Pre-paid expenses</label>
<input type="text" className="form-control" value={this.state.pre_paid_exp} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other</label>
<input type="text" className="form-control" value={this.state.other} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total current Assets</label>
<input type="text" className="form-control" value={this.state.curentAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">FiXED ASSETS</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Property and equipment</label>
<input type="text" className="form-control" value={this.state.prop_equipmnt} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Leasehold improvements</label>
<input type="text" className="form-control" value={this.state.leasehold} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Equity and other investments</label>
<input type="text" className="form-control" value={this.state.equity} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Less accumulated depreciation(-Value)</label>
<input type="text" className="form-control" value={this.state.accum_depreciation} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total fixed Assets</label>
<input type="text" className="form-control" value={this.state.fixedAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other Assets</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Charity</label>
<input type="text" className="form-control" value={this.state.Charity} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total other Assets</label>
<input type="text" className="form-control" value={this.state.otherAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Grand Total Assets</label>
<input type="text" className="form-control" value={this.state.GrandotherAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Current Liabilities</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts payable</label>
<input type="text" className="form-control" value={this.state.acc_payable} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accrued wages</label>
<input type="text" className="form-control" value={this.state.accure_wages} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accrued compensation</label>
<input type="text" className="form-control" value={this.state.accure_compens} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts receivable</label>
<input type="text" className="form-control" value={this.state.acc_receivable} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Income taxes payable</label>
<input type="text" className="form-control" value={this.state.it_tax_payble} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Unearned revenue</label>
<input type="text" className="form-control" value={this.state.uneared_revenue} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other</label>
<input type="text" className="form-control" value={this.state.OtherLiability} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total current Liabilities</label>
<input type="text" className="form-control" value={this.state.currLiabilitiesTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Long-term Liabilities</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Mortgage payable</label>
<input type="text" className="form-control" value={this.state.mortg_payable} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total Long-termLiabilities</label>
<input type="text" className="form-control" value={this.state.longtermLiabilitiesTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Owner Equity</label>
<input type="text" className="form-control" value={this.state.owner_equity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Investment capital</label>
<input type="text" className="form-control" value={this.state.investment_capital} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accumulated retained earnings</label>
<input type="text" className="form-control" value={this.state.accuml_earning} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total</label>
<input type="text" className="form-control" value={this.state.totalOwnerEquity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total Liabilities & Stockholder Equity</label>
<input type="text" className="form-control" value={this.state.totalLaibility_stackEquity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<span className="material-input"></span>
</div>
<button type="submit" className="btn btn-fill btn-rose">Submit</button>
</form>
I can't be sure without the rest of the code, but it sounds like you are using Controlled Components without updating their values with the onChange callback.
When you set the value attribute it gets "binded" to the variable you set it to. For example, <input type="text" className="form-control" value={this.state.inventories} onChange={this.handleChange} />, the value of this input will be the value of this.state.inventories. If you don't update the latter you can't change the input value. To update this value you use the onChange callback, which is set as this.handleChange, but I'm not sure you wrote the method.
On the this.handleChange method you'll use setState to change the this.state.inventories value to the value being written in the form, something like this:
handleChange(event) {
this.setState({inventories: event.target.value});
}
EDIT:
Another thing to be noted: All the inputs are using the same callback to update their values, so you can't just add this.setState({state: event.target.value}); for each one, because event.target.value will be set to the value of the input being edited when the callback is fired. You need a conditional to check which input is being edited.
One of the ways to do it is to add a name to the input and check it through event.target.name in the onChange callback. As I advised in the comment, you should read the ReactJS documentation on forms.
its very strange that i am closing the form input field tags but even though i didn’t find it in console.even my form value didn't getting posted.
here is my code
<form ng-submit="updatepersonel()" ng-repeat="update in userDetail">
<div class="form-group">
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.firstname" />
<label for="exampleInputPassword1">First Name</label>
<div class="form-group">
<label for="exampleInputPassword1">Last Name</label>
<input type="text" class="form-control" ng-model="perupdate.lastname" ng-value="update.lastname" />
</div>
<div class="form-group" />
<label for="exampleInputPassword1">Phone</label>
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.phone" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Location</label>
<input type="text" class="form-control full" ng-model="perupdate.location" ng-value="update.location" />
</div>
<button class="btn btn-success" type="submit">Update</button>
</form>
Edited::
<div class="form-group">
<form ng-submit="updatepersonel()" ng-repeat="update in userDetail">
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.firstname" />
<label for="exampleInputPassword1">First Name</label>
<div class="form-group">
<label for="exampleInputPassword1">Last Name</label>
<input type="text" class="form-control" ng-model="perupdate.lastname" ng-value="update.lastname" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Phone</label>
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.phone" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Location</label>
<input type="text" class="form-control full" ng-model="perupdate.location" ng-value="update.location" />
</div>
<button class="btn btn-success" type="submit">Update</button>
</form>
</div>
i have solved my issue.
what i was doing i was trying to get the data in ng-value.
But when i try to bind data in my ng-model i get the solution
js
$scope.perupdate= {
firstname: key.firstname,
lastname : key.lastname,
phone : key.phone,
location : key.location,
};
view
<input type="text" class="form-control full" ng-model="perupdate.firstname">