473,782 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with form checkboxes

263 Contributor
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 2293
acoder
16,027 Recognized Expert Moderator MVP
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 Contributor
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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator MVP
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 Contributor
Try this page:
http://www.avia-it.com/testaruba/
Nov 14 '09 #6
viki1967
263 Contributor
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 Recognized Expert Moderator MVP
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
6039
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 the user then deselects one or more of these checkboxes and submits the form - they're being submitted as if they were still checked, when the user has infact deselected them. I've heard that this is a common problem, but I don't seem to be...
3
2459
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 underneath. Now, the rub here is that every checkbox on the page (except the "All"s)
10
4601
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; CheckBox checkBoxArray; int BoxCount = 0; HtmlTableRow newRow; HtmlTableCell FieldCell;
4
4580
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 forum). I don't use server controls in it (apart from Page). The problem occurs on the page where visitor can post a new messages. Basically, it's a form with couple of
3
2346
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 page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
16
7303
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;" onclick="ClickBoxClick('IsProd');"> <input type="checkbox" name="IsProd" value="1" /> Is a Product </span>
1
4114
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: I dynamically add an htmlcheckbox to a webform in the pages render and set the checked value to true. When the page loads, if I remove the check from the checkbox and then submit it, in the submit event the checkbox' checked value is still...
0
1169
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. Whenever one of the two unbound checkboxes are chosen a query is run on MyTable and the field(s) MyField will be set to True or False
6
1314
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 there any shorter way. Plz help
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.