Solved

How to disable check boxes on a form using Java Script

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

Industry Leaders: 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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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