Home > database >  Reactjs input multiplication
Reactjs input multiplication

Time:06-12

In react i want to make it so that when i input a number the output is stored as that number * 60. I am very new to react so if someone can please tell me what to do.

Code :

 const Account4 = () => {
<label>From</label>
            <input
              type="number"
              placeholder="hh:mm 24 hr format"
              value={form.from}
              onChange={e => setForm({ ...form, from: e.target.valueAsNumber })} />
          </div>

CodePudding user response:

You have to multiply in the onChange event

onChange={e => 
setForm({ ...form, 
from: (e.target.value * 60) })}
  • Related