We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,318 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to maiantain checkbox state under onclick of javascript

How to maiantain checkbox state under onclick of javascript...checkbox losing its state under onclick of javascript...Onchange when set works in firefox but not in chrome and IE...Onclick works but checked state gone...

Collapse | Copy Code
<script type="text/javascript">
      function salaryshowhide() {
          var lfckv = document.getElementById("<%=chksal.ClientID%>").checked;


          if (lfckv== true) {

              document.getElementById("<%=txtsal1.ClientID%>").disabled = false;

              document.getElementById("<%=txtsal2.ClientID%>").disabled = false;

              document.getElementById("<%=currency.ClientID%>").disabled = false;

              document.getElementById("<%=permonth.ClientID%>").disabled = false;

              document.getElementById("<%=chksal.ClientID%>").checked = true;
              alert("a");
          }
          else {


              document.getElementById("<%=txtsal1.ClientID%>").disabled = true;

              document.getElementById("<%=txtsal2.ClientID%>").disabled = true;

              document.getElementById("<%=currency.ClientID%>").disabled = true;

              document.getElementById("<%=permonth.ClientID%>").disabled = true;
              document.getElementById("<%=chksal.ClientID%>").checked = false;


          }

          return false;

      }

</script>

<asp:CheckBox ID="chksal" runat="server" style="float:left" onclick="return salaryshowhide();"
/>
2
Contributors
1
Reply
1 Week
Discussion Span
2 Months Ago
Last Updated
13
Views
korathualex
Light Poster
41 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

How to maiantain checkbox state under onclick of javascript

You know it would be helpful if you post a little more ASP code showing what is this:

var lfckv = document.getElementById("<%=chksal.ClientID%>").checked;

Here is an link regarding about checkbox using Javascript with ASP:

http://www.aspsnippets.com/Articles/Implement-check-all-checkbox-functionality-in-ASPNet-GridView-control-using-JavaScript.aspx

or this:

http://www.codeproject.com/Articles/31849/Maintaining-States-of-Selected-CheckBoxes-in-Diffe

Both links have a few examples you can used. It's bit hard to really understand the issue you are having because the code you provided is incomplete.

LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0650 seconds using 2.82MB