I have a repeater with check boxes in each row. I'm trying to check the check box in row based on another check box in same row. For this I'm executing a function on OnClick event of check box and this function finds the custom attribute of the parent and checks if parent is checked or not. If returned true it checks the check box with same attribute name for child class . Th problem is I can't get the value of custom attribute of parent class. It is always undefined.
childid in jquery function is always undefined. I tried using data property too but it's of no use .
$(objid).data('chldname');
function check_view(objid) {
var childid = $(objid).attr('chldname');
if ($(objid).is(':checked')) {
$("[name=" + childid + "]").attr('checked', true);
}
}
HTML:
<td style="text-align: center">
<asp:checkbox id="cb_uploadaccess" runat="server" chldname='chld<%#Eval("ROLE_SEQ")%>' onclick='JavaScript:return check_view(this);' />
<asp:hiddenfield id="hiddenuploadaccess" runat="server" value='<%#Eval("UPLOAD_ACCESS")%>' />
</td>
<td style="text-align: center">
<asp:checkbox id="cb_viewaccess" name='chld<%#Eval("ROLE_SEQ")%>' runat="server" />
<asp:hiddenfield id="hiddenviewaccess" runat="server" value='<%#Eval("VIEW_ACCESS")%>' />
</td>
I did this in another way, just changed my JQuery function like this which worked.
function check_view(objid)
{
var childid = $(objid).attr('ID');
var childId1 = childid.substr(childid.length - 2);
if ($(objid).is(':checked')) {
$(childId1).attr('checked', true);
$("[id$=chpMain_rptDocAccessroles_cb_viewaccess" + childId1 + "]").attr('checked', true);
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments