Monday, January 17, 2011

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);" />

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Wallpapers collections