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: -
<form.... >
-
-
<input type="checkbox" name="A" value="A">A
-
<input type="checkbox" name="IN" value="IN">IN<br>
-
<input type="checkbox" name="IS" value="IS">IS<br>
-
<input type="checkbox" name="PA" value="PA">PA<br>
-
-
<input type="checkbox" name="M" value="M">M
-
<input type="checkbox" name="IN" value="IN">IN<br>
-
<input type="checkbox" name="IS" value="IS">IS<br>
-
<input type="checkbox" name="PA" value="PA">PA<br>
-
-
<input type="checkbox" name="T" value="T">T
-
<input type="checkbox" name="IN" value="IN">IN<br>
-
<input type="checkbox" name="IS" value="IS">IS<br>
-
<input type="checkbox" name="PA" value="PA">PA<br>
-
-
</form>
-
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: -
<form.... >
-
-
<input type="radio" name="macro" value="A">A
-
<input type="radio" name="macro" value="M">M
-
<input type="radio" name="macro" value="T">T
-
<input type="radio" name="macrosub" value="IN">IN<br>
-
<input type="radio" name="macrosub" value="IS">IS<br>
-
<input type="radio" name="macrosub" value="PA">PA<br>
-
-
</form>
-
Should solve your problem without JavaScript.
Many thanks Acoder for your suggestion, but I need use this page htm as explained... can you help me?
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)
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: - if (chkbox.checked) {
-
// enable/disable checkboxes here
-
}
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: - <select ...>
-
<option ...>...</option>
-
...
-
</select>
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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)
|
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;
|
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
|
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...
| |
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>
|
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...
|
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
|
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
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |