How to avoid showing an input text box so that a predetermined value is always sent on 'submit'

22 Views Asked by At

I have an input text box in react that corresponds to a transaction date. The input always has to be 'null' so that Java backend can create the date. Is there a way to eliminate this input box altogether and somehow always send the value 'null' when the submit button is pressed? Here is frontend code.

            <form onSubmit={(e) => onSubmit(e)}>
             <div className="mb-3">
                <label htmlFor="PurchDate" className="form-label">
                    Purchase Date
                </label>
                <input
                    type={"text"}
                    className="form-control"
                    placeholder="Enter purchase date"
                    name="purchDate"
                    value={newProvisioner.purchDate}
                    onChange={(e)=>onInputChange(e)}
                />
            </div>
           <button type="submit" className="btn btn-outline-primary" >Submit</button>
         <form onSubmit={(e) => onSubmit(e)}> 

Then sent to this

        const onInputChange=(e)=>{
          setNewProvisioner({...newProvisioner,[e.target.name]: e.target.value});
        };

Finally to this

        const onSubmit= async(e)=>{
           e.preventDefault();
           const prov1 = await axios.post(`http://localhost:8080/country/${countId1}/product/${prodId1}`, newProvisioner);
           const provData1 = prov1.data;        
           navigate(`/confirmarbitrage/${provData1.id}`);    
        }

The code I've given is simplified but the image below is what I see and need to fix

formImage

0

There are 0 best solutions below