Solved

How to disable check boxes on a form using Java Script

Posted on 2011-03-15
2
171 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Log4Net custom Appender not being fired. 5 74
Re-position sub-options beneath the TAB 7 73
Error on Add method 1 36
Adware on IIS hosted asp.net website 1 9
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now