I intend to pass javascript array to the server. this array will basically contain all the option values of a select tag with multiple option.
Client side
<input type="hidden" id="selectedGroupIds" name="selectedGroupIds">
<input type="submit" name="mapSubmit" value="Map Now" onclick="setGroupIds()">
function setGroupIds() {
var selectedGroupIds = [];
$('#selectedGroups option').each (function() {
selectedGroupIds.push($(this).val());
});
$('#selectedGroupIds').val(selectedGroupIds);
}
Server side
String[] groupArr = request.getParameterValues("selectedGroupIds");
System.out.println("Length = " + groupArr.length); // Prints 1 even if 2 elements in the array like [1,2]
Update I knw it can be done by getParameter() and split. Just curious to know if can be done without split by using getParameterValues()