Here is a list of different groups to choose from:
<select multiple="multiple" name="groups[]" id="groups[]" class="myclass">
<option value="1">Employees</option>
<option value="2">Vendors</option>
<option value="3">Clients</option>
</select>
I'm currently using the code below to pass the selected group to an ajax URL, but I'm only getting one group passed at a time:
<Script>
var selectedGroups = [];
var selectElement = document.getElementById("groups[]");
for (var i = 0; i < selectElement.options.length; i++) {
if (selectElement.options[i].selected) {
selectedGroups.push(selectElement.options[i].value);
}
}
xmlHttp.open("POST", "?action=ajaxcontac&groups=" + JSON.stringify(selectedGroups), true);
</Script>
Is there a way for me to pass multiple groups to the URL?
Thank you.