Reputation: 767
<#list courseGroup as eachCourse>
<tr>
<td>
<input id="${eachCourse}" type="checkbox" onClick="javascript:getBatchNos('${eachCourse}');"> <label for="${eachCourse}">${eachCourse}</label>
</td>
<tr>
</#list>
function getBatchNos(course) {
// I dont have id of the element to check if it is checked
// variable course is holding the actual Id of the element
// Please help me how I would be able to access this element using variable course
if (jQuery("#course").is(":checked")) {
}
}
I want to find out if check box is checked or unchecked with a variable having id of the checkbox. If it is not possible please suggest me if there is any other way of doing it.
Upvotes: 0
Views: 171
Reputation: 9146
You're passing a variable in that looks like your ID, so why not use that?
function getBatchNos(course) {
// I dont have id of the element to check if it is checked
// variable course is holding the actual Id of the element
// Please help me how I would be able to access this element using variable course
if (jQuery("#"+course).is(":checked")) {
}
}
Upvotes: 1