I want to push { "studentid": achecked[index].value } this into a array, but if i push it my array is like this (2) [{…}, {…}] and not my checkbox value.
this is my code:
var achecked = $("form input:checkbox:checked");
var values = [];
achecked.each(function (index) {
var student = { "studentid": achecked[index].value };
values.push(student);
});
console.log(values);
var postdata = {
'displayname': $("#displayname").val(),
'email': $("#email").val(),
'students': [
]
};
postdata.students = values;
<input type="checkbox" name="toevoegen" value="10" />
<button class="btn btn-success" id="aanmaken">Aanmaken</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
does someone knows and could help me?
{...}in your console log output?