Handle the onChange event on a Select element in React

when I select an option I want to get data of that selectedoptions and return them into another text input

here is my code

 <CFormSelect aria-label="Default select example" size='lg' name='product' id='product' value={selectProduct} onChange={handleChangle} > **<option > -- Choose Product --</option> {products.map((product) =>{ return <option key={product._id} value={product._id} >{product.designation}</option> })}** </CFormSelect> <CRow> <CCol className='col-sm-3'> <CFormLabel htmlFor="exampleFormControlInput1">Qty in Stock </CFormLabel> <CFormInput type="text" size="lg" name='qteInStock' id='qteInStock' value={qteInStock} placeholder="Quantite" aria-label="lg" onChange={(e) => setQteInStock(e.target.value)} disabled /> </CCol> <CCol className='col-sm-3'> <CFormLabel htmlFor="exampleFormControlInput1">Quantity </CFormLabel> <CFormInput type="text" size="lg" name='quantity' id='quantity' value={quantity} placeholder="Quantite" aria-label="lg" onChange={(e) => setQuantity(e.target.value)} /> </CCol> 

here is my onchange function

const handleChangle = (e) =>{

}

I don't know what to put inside to change the two input,i want to get back the product quantity and the product price... am stuck since yesterday

1 Answer

I have try to understand what you want to do, is it something like that ?

  • User select the product via the
  • Once selected, user can see the quantity in stock
  • Once selected, user can chose an amount for quantity desired
  • Total price is automatically print, sync with quantity desired.

I'm available if you have any questions, or need some help, can MP me.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like