[jQuery] Simple checkbox function not working

[jQuery] Simple checkbox function not working


I'm trying to use the val( val ) method to check checkboxes but
nothing happens. I've checked that the names of i and the value of
the input field are identical. Am I doing something wrong?
for (var i in p) {
$(":input[id=" + i + "]").each( function () {
if ($(this).attr("type") == "checkbox" && p[i] ==
"True") {
$(this).val(i);
alert($(this).attr("value") + ":" + i);
} else {
$(this).val(p[i]);
}
});
$("body").append(i + ": " + p[i] + "<br />");
}
The alert shows: "grad_umcscu:grad_umcscu"
All the other form field setting seems easy, is there a better way to
do this or at least a way to make this work?
Thanks.