[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CheckBox - onchange event?

Posted on 2006-06-20
2
Medium Priority
?
1,964 Views
Last Modified: 2010-08-05
Hi all!

I have a HUGE form (over 250 fields) which contains just about every type of input your could imagine.

The customer would now like to have two of the checkboxes on the form be relative to each other...they'd be performing more like radio buttons, in that if one is checked, the other will uncheck.

I don't think I can do an autopostback, because I don't want the form submitted until all the values are completed and these checkboxes are in the middle of the page.

Can anyone show me a function that I can apply to an onchange event that will check to make sure that if Checkbox1 is selected then Checkbox2 isn't and vice-versa?

Thanks!
0
Comment
Question by:ClassyLinks
[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 7

Accepted Solution

by:
kGenius earned 2000 total points
ID: 16945916
add this script to your html head

<script type="text/javascript">
function ReverseCheckBox(sender, linkedControl) {
if (document.getElementById(sender).checked==true) {
document.getElementById(linkedControl).checked = ! document.getElementById(sender).checked;
}
}
</script>

You must add in code behind the attribute:
onclick="ReverseCheckBox('THE ID OF THE CHECKBOX', 'THE ID OF THE LINKED CHECKBOX');" to every checkbox

your output must become something like:
 <asp:CheckBox ID="CheckBox1" runat="server" onclick="ReverseCheckBox('CheckBox1', 'CheckBox2');"/>
 <asp:CheckBox ID="CheckBox2" runat="server"  onclick="ReverseCheckBox('CheckBox2', 'CheckBox1');"/>

kGenius
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 16951749
Wonderful!

Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

656 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