Monday, January 25, 2010

Get CheckBox Text and Checked property using Javascript

function checkboxClick(obj) 
{ 
    var lbl = obj.nextSibling; 
    while(lbl.nodeName.toLowerCase()!='label')  
        lbl=lbl.nextSibling; 
  
    alert(lbl.innerHTML); 
     
    if (obj.checked) 
        alert('checked'); 
    else 
        alert('not checked'); 
} 
  
  
  
  
<asp:CheckBox ID="chk" runat="server" Text="Check" 
onclick="checkboxClick(this);" />

No comments:

Post a Comment