Solved

How to disable check boxes on a form using Java Script

Posted on 2011-03-15
2
175 Views
Last Modified: 2012-05-11
This is more of a Java script question. I see "JScript" as a choice of where to post this. I hope JScript is an abbreviation for Java Script.

I have an Asp.net web form with several check boxes on it. If someone checks one check box I need to then disable the other check boxes on the form. If they un-check the check box I need to re-enable the other check boxes on the form. Does anyone know how I can do this using Java Script?
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 35137663
0
 
LVL 7

Expert Comment

by:foobarr
ID: 35157573

in markup
<asp:checkbox id="check1" runat="server" />
<asp:checkbox id="check2" runat="server" />
<asp:checkbox id="check3" runat="server" />

in code behind
on page load or wherever you are initializing

check1.attributes.add("onclick", "disableBoxes(this)")
check2.attributes.add("onclick", "disableBoxes(this)")
check3.attributes.add("onclick", "disableBoxes(this)")


in javascript in the markup

function disableBoxes(item)
{
  if (item.id == 'check1'){
       document.getelementbyid("<%= check2.ClientId%>").disabled = true;
       document.getelementbyid("<%= check3.ClientId%>").disabled = true;
  }
  else if (item.id == 'check2') {
    document.getelementbyid("<%= check1.ClientId%>").disabled = true;
       document.getelementbyid("<%= check3.ClientId%>").disabled = true;
  }
 else if (item.id =='check3') {
 {
    document.getelementbyid("<%= check1.ClientId%>").disabled = true;
       document.getelementbyid("<%= check2.ClientId%>").disabled = true;
}
}

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question