472,952 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

Problem with form checkboxes

263 100+
I need one function javascript that:

1) when I enter in this htm page I see enabled only checkbox of categories A, M and T; checkboxes of microcategories all disabled;

2-a) If I select the checkbox of macrocategory A, M and T checkboxes all disabled;
2-b) If I select the checkbox of macrocategory M, A and T checkboxes all disabled;
2-c) If I select the checkbox of macrocategory T, A and M checkboxes all disabled;

3) If I select the checkbox macrocategory A enable only the checkboxes of microcategories corresponding to macrocategory A;
4) If I select the checkbox macrocategory M enable only the checkboxes of microcategories corresponding to macrocategory M;
5) If I select the checkbox macrocategory T enable only the checkboxes of microcategories corresponding to macrocategory T;

6) One checkbox of macrocategory and one checkbox of microcategory selected for the form it's valid.


My form in the page htm:

Expand|Select|Wrap|Line Numbers
  1. <form.... >
  2.  
  3. <input type="checkbox" name="A" value="A">A
  4. <input type="checkbox" name="IN" value="IN">IN<br>
  5. <input type="checkbox" name="IS" value="IS">IS<br>
  6. <input type="checkbox" name="PA" value="PA">PA<br>
  7.  
  8. <input type="checkbox" name="M" value="M">M
  9. <input type="checkbox" name="IN" value="IN">IN<br>
  10. <input type="checkbox" name="IS" value="IS">IS<br>
  11. <input type="checkbox" name="PA" value="PA">PA<br>
  12.  
  13. <input type="checkbox" name="T" value="T">T
  14. <input type="checkbox" name="IN" value="IN">IN<br>
  15. <input type="checkbox" name="IS" value="IS">IS<br>
  16. <input type="checkbox" name="PA" value="PA">PA<br>
  17.  
  18. </form>
  19.  
Nov 13 '09 #1
7 2258
acoder
16,027 Expert Mod 8TB
My suggestion:

Use radio buttons for A, M & T; and only have one set of radio buttons for IN, IS and PA:
Expand|Select|Wrap|Line Numbers
  1. <form.... >
  2.  
  3. <input type="radio" name="macro" value="A">A
  4. <input type="radio" name="macro" value="M">M
  5. <input type="radio" name="macro" value="T">T
  6. <input type="radio" name="macrosub" value="IN">IN<br>
  7. <input type="radio" name="macrosub" value="IS">IS<br>
  8. <input type="radio" name="macrosub" value="PA">PA<br>
  9.  
  10. </form>
  11.  
Should solve your problem without JavaScript.
Nov 13 '09 #2
viki1967
263 100+
Many thanks Acoder for your suggestion, but I need use this page htm as explained... can you help me?
Nov 13 '09 #3
Dormilich
8,658 Expert Mod 8TB
Acoder’s code exactly fits requirements 3 to 6.
requirement 2 does not apply (you can’t select more than one)
Nov 14 '09 #4
acoder
16,027 Expert Mod 8TB
And requirement 1 is no longer needed either.

If you insist (or more for the benefit of someone wanting to know how it could be done), set the disabled property of the checkboxes to true/false to disable/enable when a checkbox is clicked. To decide whether to enable/disable, check the "checked" property:
Expand|Select|Wrap|Line Numbers
  1. if (chkbox.checked) {
  2.     // enable/disable checkboxes here
  3. }
My opinion: too much unnecessary code for something that can be done with pure HTML. If you want an alternative to radio buttons, use two select boxes:
Expand|Select|Wrap|Line Numbers
  1. <select ...>
  2. <option ...>...</option>
  3. ...
  4. </select>
Nov 14 '09 #5
viki1967
263 100+
Try this page:
http://www.avia-it.com/testaruba/
Nov 14 '09 #6
viki1967
263 100+
I have changed the input checkbox with input radio:

http://www.avia-it.com/testaruba/

But I have problem with control the exact combination of the radio:

It's OK: http://www.avia-it.com/testaruba/immagine_1.jpg
it's KO: http://www.avia-it.com/testaruba/immagine_2.jpg

Can you help me?
Nov 17 '09 #7
acoder
16,027 Expert Mod 8TB
Hmm, ok, it seems you didn't describe the problem properly in the first post.

I assumed that all 3 main options A, M and T had the same sub-options. Since it isn't, and the list of options is long, it would probably be more appropriate to use select drop-downs. Then when, for example, M is selected, the corresponding options are loaded into the second drop-down.

3 basic steps:
1. An array containing the options
2. Two drop-downs in the HTML
3. When the first drop-down option is changed, load the new options into the second one.

PS. you could go the way that you originally stated with checkboxes, but that takes up too much space on the screen.
Nov 18 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Claire | last post by:
Hello, I am having a problem in my struts application with the checkboxes in my form. I have an array of checkboxes, some of which may be already selected when the form loads. My problem is when...
3
by: Adam Toline | last post by:
In reference to the following: http://www.bellecose.com/form.htm At the top of each column there is a box for "All". When one is checked I need to check all of (and only) those boxes...
10
by: Steven | last post by:
I create the checkboxes dynamically on my webform (aspx). after I create them, when I check any of the checkboxes, nothing happens. Here is my code ... ArrayList LayerNameList1 = LayerNameList;...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
16
by: GTi | last post by:
I want to use a 'smarter' checkbox using span. When a user press the text the checkbox is checked. But this dos't work as expected. Any idea? <span style="cursor:pointer;"...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
0
by: Henrootje | last post by:
I have a continous form. That form has three checkboxes, two unbound and one (MyCheckbox1) bound to MyField. The whole form is bound to the table tblMyTable which contains the field MyField. ...
6
by: rohit reja | last post by:
Hi everyone I am developing a website..the form in my php page has a lot of checkboxes..to set differebt options. Now how do i write mysql query for that form according to checkbox selected..is...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.