Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda