I have the following loop:
var array = ["Value 1", "Value 2", "Value 3"];
var textArray = ["Text 1", "Text 2", "Text 3"];
array.forEach(function(arr) {
$(".department").append('<option value="' + array + '">' + textArray + '</option>');
});
What I'm trying to achieve is the <option> label to use the text but its value to use the array array.
If I do the following:
$(".filterSection .department").append('<option value="'+array+'">'+textArray+'</option>');
My output looks like this:
<option value="Value 1,Value 2,Value 3">Text 1</option>
<option value="Value 1,Value 2,Value 3">Text 2</option>
Whereas I'm looking for:
<option value="Value 1">Text 1</option>
<option value="Value 2">Text 2</option>
<option value="'+array+'">to<option value="'+arr+'">array.forEach(function(item, i) { $(".department").append('<option value="' + item + '">' + textArray[i] + '</option>'); });