I am trying to get a 2D array using the document.getElementById("clients").value.split(','); as I need to split the 2d array.
I have tried the above code/step.
<input type="hidden" id="clients" name="clients" value="{{clients}}">
var displayClient = [];
var clients_array = document.getElementByName("clients").value.split(',');
var itemDisp = [];
var arrayLength = clients_array.length;
for (var i = 0; i < arrayLength; i++) {
displayClient.push(clients_array[i] + ' - ' + clients_array[i]);
itemDisp.push({ label: displayClient[i]});
}
//the 2d array is as follows
[['1', 'client 1'], ['2', 'client 2']]
the actual result at the moment is: [['1' (new line) 'client 1']... while I would like to get: 1 - client 1...