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

183
Vistas
Is there a way to get the html of form fields including current values?

Is there a way to get the resulting HTML of form fields where the user has entered data? For example, I only seem to be able to retrieve something like this using innerHTML:

<input type="text" />
<textarea></textarea>

But I would like to get something like this:

<input type="text" value="John Smith" />
<textarea>Hello! How are you today?</textarea>

Edit:

Here's code for a minimum reproducible example:

function go() {
  alert(document.getElementById('example').innerHTML);
}
<div id=example>
  <input type=text />
  <textarea></textarea>
  <input type=button value=go onclick="go()" />
</div>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Yes, you can get value from html form by using javascript. You can get value which user input in the form.

You have to declare id in input field or textarea field.

<input type="text" id="name" value="John Smith" />
<textarea id="name">Hello! How are you today?</textarea>

Now get the field by using javascript.

const input = document.getElementById("id")

Now to get value, just use value property of this element.

input.value

or you can use it directly

document.getElementById("id").value

For getting entire dump from a html form.

<form action="" method="post" id="BookPackageForm">

Then fetch the form element by using forms object.

var formEl = document.forms.BookPackageForm;

Get the data from the form by using FormData objects.

var formData = new FormData(formEl);

Get the value of the fields by the form data object.

var name = formData.get('name');
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