html - Setting Checkbox in a Table Using Javascript -
trying set checkbox inside table. thought straightforward , similar doing in form.
i can form , getting stuck when checkbox in table.
when checkbox in form use:
<form name="access_menu_form"> <input type="checkbox" name="mybox_name" id="mybox_id" value="1"> </form> document.access_menu_form.mybox_name.checked == true
which works great!!
i know missing key point dom. trying set checkbox have in table fails using similar technique fails:
my table:
<table name="access_table"> <thead> <tr> <th>area</th> <th>item</th> <th>access</th> </tr> </thead> <tr> <td><input type="checkbox" name="mybox_name" id="mybox_id" value="1"></td> <td><input type="checkbox" name="mybox1_name" id="mybox1_id" value="1"></td> <td></td> </tr> </table>
my script
document.access_table.mybox_name.checked = false;
i error: uncaught typeerror: cannot read property 'mybox' of undefined
document.mybox_name.checked = false;
i error: uncaught typeerror: cannot set property 'checked' of undefined
- use 'checked' attribute
- let javascript find checkbox using following, document.getelementbyid('mybox_id')
Comments
Post a Comment