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

x
?
Solved

Check Boxes / Radio Buttons Multipole Selections

Posted on 2000-02-22
10
Medium Priority
?
201 Views
Last Modified: 2012-05-04
I would like to have a form where aa user can select multiple choices.  I can do this with checkboxes but I would like to have an "All Of The Above" which would deselect all of the checkboxes from above.

Example
[] Archive
[] Current Issue
[] Another Choice

[] All of the Above

The user could select archive and Another choice, but if he selected All of the above I would like the choices above that were selected to be deselected.  Is there a way to do this?


0
Comment
Question by:gretchen
[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
  • 6
  • 2
  • 2
10 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 2545575
Here goes the answer:

<html>
<head>
<title>Example</title>
<script language="javascript">
<!--
function select_one() {
 document.myform.ch_all.checked = false
}

function deselect_all() {
 for (var i = 0; i<document.myform.elements.length; i++) {
  sName = document.myform.elements[i].name
  if ((sName .indexOf('ch_') != -1) && (sName != "ch_all")) {
   document.myform.elements[i].checked = false
  }
 }        
}
//-->
</script>
</head>
<body>
<form name="myform">
<input type="checkbox" name="ch_archive" onClick="if (this.checked) select_one();">Archive<br>
<input type="checkbox" name="ch_current" onClick="if (this.checked) select_one();">Current<br>
<input type="checkbox" name="ch_another" onClick="if (this.checked) select_one();">Another Choice<br><br>
<input type="checkbox" name="ch_all" onClick="if (this.checked) deselect_all();">All of the abovee<br>
</form>
</body>
</html>


xabi
0
 
LVL 5

Expert Comment

by:nathans
ID: 2546034
That is Correct!!!
0
 
LVL 8

Expert Comment

by:xabi
ID: 2546144
Points? :)

xabi
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Accepted Solution

by:
xabi earned 80 total points
ID: 2546205
Here goes a better script:
------- 8< -------- 8< ---------
<html>
<head>
<title>Example</title>
<script language="javascript">
<!--
function deselect_all(idform) {
 for (var i = 0; i<idform.elements.length; i++) {
  sName = idform.elements[i].name
  if ((sName.indexOf('ch_') != -1) && (sName != "ch_all")) {
   idform.elements[i].checked = false
  }
 }        
}
//-->
</script>
</head>
<body>
 <form name="myform">
  <input type="checkbox" name="ch_archive" onClick="if (this.checked) this.form.ch_all.checked = false;">Archive<br>
  <input type="checkbox" name="ch_current" onClick="if (this.checked) this.form.ch_all.checked = false;">Current<br>
  <input type="checkbox" name="ch_another" onClick="if (this.checked) this.form.ch_all.checked = false;">Another Choice<br><br>
  <input type="checkbox" name="ch_all"     onClick="if (this.checked) deselect_all(this.form);">All of the above<br>
 </form>
</body>
</html>
----------- 8< ------- 8< --------
xabi
0
 
LVL 5

Expert Comment

by:nathans
ID: 2546278
Hey, While your on a roll can you make a box to select ALL?
0
 
LVL 8

Expert Comment

by:xabi
ID: 2546437
Here goes the code for that:

-------- 8< --------- 8< -------
<html>
<head>
<title>Example</title>
<script language="javascript">
<!--
function deselect_all(idform, boxname, new_state) {
 for (var i = 0; i<idform.elements.length; i++) {
  sName = idform.elements[i].name
  if (sName.indexOf('ch_') != -1) {
   idform.elements[i].checked = new_state
  } else {
   if ((sName.indexOf('ch') != -1) && (sName != boxname)) {
    idform.elements[i].checked = false
   }
  }
 }        
}
function unmark_all(idform) {
 idform.chm_all.checked = false
 idform.chu_all.checked = false
}
//-->
</script>
</head>
<body>
 <form name="myform">
  <input type="checkbox" name="ch_archive" onClick="unmark_all(this.form);">Archive<br>
  <input type="checkbox" name="ch_current" onClick="unmark_all(this.form);">Current<br>
  <input type="checkbox" name="ch_another" onClick="unmark_all(this.form);">Another Choice<br><br>
  <input type="checkbox" name="chm_all"   onClick="if (this.checked) deselect_all(this.form, this.name, true);">Mark all<br>
  <input type="checkbox" name="chu_all"   onClick="if (this.checked) deselect_all(this.form, this.name, false);">Unmark all<br>
 </form>
</body>
</html>
----------- 8< --------- 8< -----

I'm so busy, so I will not change anything more today.

xabi
0
 
LVL 8

Expert Comment

by:xabi
ID: 2546440
And just for 20 points :) ...
0
 

Author Comment

by:gretchen
ID: 2548611
Thank You very much
gl
0
 

Author Comment

by:gretchen
ID: 2548637
Quick Question:  Can you recommened a book or website that talks about how to deal with the elements of checkboxes, forms, radio buttons, and the document object.  Things of this nature.  Anything would help.

gl
\
0
 
LVL 8

Expert Comment

by:xabi
ID: 2549509
yep:

For fomrs:
http://developer.irt.org/script/script.htm

and for anyother thing:
http://www.irt.org

xabi
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

649 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