code_junkie

Change the Text of an asp:CheckBox when clicked

Nov 13th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <asp:CheckBox ID="CheckBox1" runat="server" Text="Open" />
  2.  
  3. function changeCheckboxText(checkbox)
  4. {
  5. if (checkbox.checked)
  6. checkbox.nextSibling.innerHTML = 'on text';
  7. else
  8. checkbox.nextSibling.innerHTML = 'off text';
  9. }
  10.  
  11. <asp:CheckBox runat="server" ID="chkTest" onclick="changeCheckboxText(this);" />
  12.  
  13. $("input[id$=CheckBox1]").click(function() {
  14. if ($(this).attr("checked")) {
  15. $(this).next("label:first").text("Open");
  16. }
  17. else {
  18. $(this).next("label:first").text("Close");
  19. }
  20. });
  21.  
  22. CheckBox1.Attributes.Add("JavaScipt")
Add Comment
Please, Sign In to add comment