How to pass array value in input?

<form action="url" method="POST" target="_blank">
 <input type="hidden" name="id[]" value>
 <input class="print-all-btn" type="submit" name="send" value="send">
</form>


printAll.on("click", function(){
 var array = [];
 $('input.select-inv-check:checked').each(function() {
array.push($(this).data('id'));
});
 document.getElementsByName("id[]").value = array;
 console.log("id[]", document.getElementsByName("id[]").value);
return;
});

in the console displays the array, and the new page is blank. But if the static is manually to drive, then on the page have details.

<form action="url" method="POST" target="_blank">
 <input type="hidden" name="id[]" value="9173981723917293">
 <input type="hidden" name="id[]" value="9173981723917293">
 <input type="hidden" name="id[]" value="9173981723917293">
 <input type="submit" name="send" value="send">
</form>
June 14th 19 at 20:41
1 answer
June 14th 19 at 20:43
Why?
for form onSubmit="sendAdditionalData(this);return false;"

sendAdditionalData function(form, params, by responsehandler) 
{
 if (typeof(form)=='string') form=document.getElementById(form);
 var formData = new FormData(form);
 if (params!=null)
{
 for (paramName in params)
{
 formData.append(paramName, params[paramName]);
}
}
 well, here sobsno throw the data where it is necessary
 makeRequest(form.action, formData, by responsehandler);
 }
I need to select documents, click on print and print all selected documents in a new page after clicking the button. on the server all the time there is an empty array. could it be so that a request to the server goes faster while I pick up all selected documents in an array? - Romaine.Stiedemann commented on June 14th 19 at 20:46
I don't see where you have submitting the form.
if the submit button she printAll so it of course is. - royal.Hettinger commented on June 14th 19 at 20:49
so is pressing the button I collect in an array the selected documents and send. and what then if it is not correct - Romaine.Stiedemann commented on June 14th 19 at 20:52
Put the onSubmit event on the form - royal.Hettinger commented on June 14th 19 at 20:55
did not understand how to hang up ? - Romaine.Stiedemann commented on June 14th 19 at 20:58
exactly like you hang with a click. Not on click and submit and not a button on the form - royal.Hettinger commented on June 14th 19 at 21:01

Find more questions by tags JavaScript