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

225
Views
FormData won't load inputs of form

My Code

<!DOCTYPE html>
<html>

<body>
  <div id="form-sample">
    <form enctype="multipart/form-data">
      <input type="text" name="sample-text" />
      <input type="radio" name="sample-radio" value="yes" />
      <input type="radio" name="sample-radio" value="no" />
      <input type="file" name="images[]" multiple="multiple" />
      <input type="submit" value="Fetch Data" />
    </form>
  </div>

  <script>
    function onSubmitForm(e) {
      e.preventDefault();
      const fD = new FormData(document.querySelector("#form-sample form"));
      console.log(fD.entries()); // get an empty FormData Iterator
    }

    document.addEventListener('DOMContentLoaded', function(e) {
      document.querySelector("#form-sample form").addEventListener("submit", onSubmitForm, false);
    });
  </script>
</body>

</html>

Why doesn't FormData load the <form> inputs and why is that not returning an exception?

Actually trying this code on latest Firefox version (v95.0)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. You can iterate through the Iterator: https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries

  2. You can get the values one by one: https://developer.mozilla.org/en-US/docs/Web/API/FormData/get

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!