I have a checkbox that is being echoed by PHP. So, the id of the checkbox will be dynamic.
So, I would like use a variable for document.getElementById().
Below is my PHP code:
Then here is my Javascript codeCode:echo "<td><input type='checkbox' name='edit$count' value='1' onclick='test($count)'></td>";
However, when I clicked on the checkbox, there is no alert. Please let me know if there is anything wrong with my code.Code:function test(v) { var edit = "edit" + v; if(document.getElementById(edit).checked==true){ alert(edit); } }
Any help is much appreciated. Thank you.
EDIT: I found the issue, I am missing an id for the checkbox.


Reply With Quote

Bookmarks