I'm trying to retrieve the values in a series of checkboxes:
$(document).ready(function() {
var folders = document.getElementsByName('note-behaviour-folder-add[]');
for(var x = 0; x < folders.length; x++){
if ((folders[x].type === "checkbox") && (folders[x].checked)) {
alert("Yes!");
}
}
});
While there is data in the named elements, the above code appears not to be retrieving any of it. I also tried the jQuery alternative:
var folders = $("[name='note-behaviour-folder-add[]']");
But that went crazy and grabbed everything in the application.
As for the HTML itself:
<div class="note-behaviour-folder-box" id="note-behaviour-folder-box-2">
<input type="checkbox" id="note-behaviour-folder-item-2" name="note-behaviour-folder-add[2]" value="2" checked="checked">Plot
<dl>
<dt><label for="note-behaviour-folder-item-select-2">Behaviours</label></dt>
<dd><select name="note-behaviour-folder-item-select-2" class="chzn-select">
<option value="1">List</option>
<option value="2">Paragraph</option>
<option value="3" selected="selected">Chapter</option>
</select></dd>
</dl>
</div>
Any ideas?