I have a form that has an array of checkbox elements, such as this:
etc.
I have also a trash icon displayed with each checkbox :
etc.
Now, when I click one of the trash icons, I switch the trash.png image with trash-remove.png image and I try to set the associated checkbox to "true". I get the image changed BUT I cannot get the associated checkbox to show "checked".
Below is my remFavorite javascript code:
function remFavorite(id, container) {
document.getElementById(container).innerHTML = '<img src="/ideabooks/images/trash-removed.png" onClick="addFavorite("'+id+'", "'+container+'", "'+fid+'")"></div><input type="hidden" name="rem['+id+']" value="Yes" />';
var checkboxes = document.getElementsByName('select[]');
checkboxes[id].checked=true;
checkboxes[id].value="on";
alert("6 id="+id+" checkedbox[id]="+checkboxes[id].checked+" checkedbox[id]="+checkboxes[id].value); }
The Alert on line 6 shows that checkboxes[1].checked is set to "true" and that checkboxes[1].value is set to on", but when the script completes, the checkbox is not checked??
You help is greatly appreciated:)
Aucun commentaire:
Enregistrer un commentaire