posted 11 years ago
In my application, data is retrieved from database and then checkboxes are created dynamically. Following is the code
When the checkbox is checked/unchecked, it should call another function named "checkboxClicked" in the above code
Following the function code
Thus, if 4 checkboxes are created , their name would be myCheckbox0,myCheckbox1,myCheckbox2,myCheckbox3 respectively. This is implemented in the 1st code posted
Now, when the 2nd checkbox with id myCheckbox1 is checked , the checkboxClicked function is called. This function contains the parameter, which is passed as a var i. The function runs and It alerts the id, i.e myCheckbox1. However, it alert false.
This happens with all checkboxes. I need that if the checkbox is checked, it should alert true, and if unchecked, it should alert false.
What is wrong with my code?