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

144
Views
assigning values to input array

if I have this:

function add(){
  var val = document.getElementById("item").value;
  
  document.getElementById("items").value = val;
  
}
<table>
    <input type="text" name="item" id="item" value="" >
    <input type="hidden" name="items[]" id="items[]" value="" >
    
    <button onclick="add()" type="button"> Add</button>
    
</table>

so I just want add some values to input items[], It's possible? in javascript I use push(), but in this case I don't know what to do.

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

0

You should create a new items[] element for each value that you're adding. Then the middleware on the server should automatically create an array with all these values.

function add(){
  var val = document.getElementById("item").value;
  
  var item = document.createElement("input");
  item.type = "hidden";
  item.name = "items[]";
  item.value = val;  
  document.getElementById("form").appendChild(item);
}
<form id="form">
    <input type="text" name="item" id="item" value="">
    
    <button onclick="add()" type="button"> Add</button>
    
</form>

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!