?
Solved

How to disable check boxes on a form using Java Script

Posted on 2011-03-15
2
Medium Priority
?
176 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 1000 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

Technology Partners: 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 have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 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