I am using dropzone.js to send some files to my server and the response that comes back is always the id of the attachment which is great. Happy that's finally working.
However, I am trying to populate an input field with a comma separated string of IDs as they are returned from the server. This may be when images are first uploaded, or when further images are added.
I need to take the value of an input, then add to it. I can't figure out where Im going wrong.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- The HTML Input when no images are uploaded -->
<input type="hidden" id="media-ids" name="media-ids" value="">
<!-- The HTML Input (expected when images are uploaded) -->
<input type="hidden" id="media-ids" name="media-ids" value="12,13,14,15">
// inside the jQuery (ajax success function)
var current = jQuery('#media-ids').val();
var currentArray = current.split(',');
var newArray = currentArray.push(response);
var inputString = newArray.join(); //ERROR - .join() is not a function
jQuery('#media-ids').val(inputString);
console.log(inputString); //Returns 2 (I'm guessing that's false)