Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda