I have this code:
<select multiple id="test">
<option value="A">Option A</option>
<option value="B">Option B</option>
<option value="C">Option C</option>
<option value="D">Option D</option>
</select>
If the user selects A and C, is there a way to put those values in an array? If the select is not multiple, I can use option = document.getElementById('test').value;. But if it's multiple then I don't know how to do it. Because we can only use one value attribute, not an array of attributes. The documentations for <option> and <select> aren't useful. There is also a similar question but I'm not sure how to apply it.
What I want is to put them into a string:
string = 'You select` + optionarray[0] + ' and ' + optionarray[1] + ' and ' + optionarray[2] + ... //until there is no more element left