Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
how to get the value of two p tag in react using useState in ReactJs

I'm trying to get the value of two p tags at the same time to push those values to the backend.

my useState declaration const [isOffer, setIsOffer] = useState({ contractorName: "", newOffer: "" });

const handleChange = (e) => {
    const { name, value } = e.target;`

    setIsOffer({
      ...isOffer,
      [name]: value,
    });
  };

how I handle the form submission

  const handleFormSubmit = async (event) => {
    event.preventDefault();
    try {
      await approveOffer({
        variables: {isOffer, projectId },
      });
    } catch (err) {
      console.log(err);
    }
  };


<form className="flex-row justify-center justify-space-between-md align-stretch" 
 onSubmit={handleFormSubmit}>
<p
className="card-body"
name="contractorName"
value={offer.ContractorName}
onClick={handleChange}
>
Offer By:{offer.ContractorName}
 </p>
 <p name="newOffer"
 value={offer.newOffer}
 onClick={handleChange}
 >
 The Offer Value:{offer.newOffer}{" "}
 </p>
<button className="btn d-block w-100" type="submit">
 </form>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you will replace the handleChange code with the below code:

Existing:

const { name, value } = e.target;

Replace:

const name = e.target.getAttribute('name');
const value =  e.target.getAttribute('value');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!