I have the following HTML:
<div id="tagType1">
<input id="tag1" name="tagType1" value="tag1" type="checkbox" />
<input id="tag2" name="tagType1" value="tag2" type="checkbox" />
<input id="tag3" name="tagType1" value="tag3" type="checkbox" />
<input id="tag4" name="tagType1" value="tag4" type="checkbox" />
</div>
<div id="tagType2">
<input id="tag5" name="tagType2" value="tag5" type="checkbox" />
<input id="tag6" name="tagType2" value="tag6" type="checkbox" />
<input id="tag7" name="tagType2" value="tag7" type="checkbox" />
<input id="tag8" name="tagType2" value="tag8" type="checkbox" />
</div>
And the following jQuery:
$.get($("#filter form").attr("action") + "/count", function (data, textStatus, jqXHR) {
$('#workCount span').text(data.toString());
});
And the following method:
public JsonResult Count(string[] tagType1 = null, string[] tagType2 = null)
{
// Do something
}
My question is, how do I group the inputs from my two containers within jQuery
Try to use $(“:input”).serializeArray();
.serializeArray() Returns: Array
it Encode a set of form elements as an array of names and values.
http://api.jquery.com/serializeArray/