Uncaught TypeError: Object has no method 'setAttribute'
I am having some trouble with my nested for loop. I am trying to determine
the value of checked checkboxes in my form. I was told that the whole
thing should formatted like so:
for(checkboxes loop){
for(item.appointmentType[1] loop){
if(statement conditional){
set checks code
}
}
}
But I just can not seem to get it written correctly because I have
received an error saying, Uncaught TypeError: Object has no method
'setAttribute'
Below is the code that I am working with. Can someone help me correct it
that may know what I am talking about?
var checkboxes = document.forms[0].appointmentType;
for(var i=0; i<checkboxes.length; i++){
for(var j=0; j<item.appointmentType[1].length; j++){
if(checkboxes[i].value === item.appointmentType[1][j]){
item.appointmentType[1][j].setAttribute("checked", "checked");
}
}
}
Thanks.
No comments:
Post a Comment