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

173
Views
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 answers
Answer question

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 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!