Hi all,
I am newcomer in HTML, Javascript,
I want to create two select controls S1, S2.
There are 3 options: ALL, A, B in S1;
When select A in S1, It let you select A1, A2 in S2,
Where select B in S1, It let you select B1, B2 in S2;
When select ALL in S1, It let you select A1, A2, B1, B2 in S2
The default selection in S1 is ALL,
Can somebody give me some suggestion?
Thanks advance
Carl 1 5488
Carl Wu wrote: I want to create two select controls S1, S2.
<select name="S1">
</select>
<select name="S2">
</select>
There are 3 options: ALL, A, B in S1;
<select name="S1">
<option>ALL</option>
<option>A</option>
<option>B</option>
</select>
When select A in S1, It let you select A1, A2 in S2,
Where select B in S1, It let you select B1, B2 in S2;
When select ALL in S1, It let you select A1, A2, B1, B2 in S2
<script type="text/javascript" language="JavaScript">
<!--
function enableItems(o)
{
if (!o || !o.form || !o.form.elements)
return false;
var
o2 = o.form.elements['S2'],
a1 = o2.options[0],
a2 = o2.options[1],
b1 = o2.options[2],
b2 = o2.options[3];
if (o2 && a1 && typeof a1.disabled != "undefined")
{
switch (o.selectedIndex)
{
case 0: // ALL
a1.disabled = false;
if (a2)
a2.disabled = false;
if (b1)
b1.disabled = false;
if (b2)
b2.disabled = false;
break;
case 1: // A
a1.disabled = false;
if (a2)
a2.disabled = false;
break;
case 2: // B
if (b1)
b1.disabled = false;
if (b2)
b2.disabled = false;
}
}
}
//-->
</script>
<form action="...">
<select name="S1" onchange="enableItems(this)">
<option>ALL</option>
<option>A</option>
<option>B</option>
</select>
<select name="S2">
<option>A1</option>
<option>A2</option>
<option>B1</option>
<option>B2</option>
</select>
</form>
Untested.
The default selection in S1 is ALL,
It is the default because it is the first item.
Can somebody give me some suggestion?
See above. And before you post to a newsgroup the next time, you should get
a minimum clue of what you are doing (by reading documentations, FAQS aso.)
This is not a support forum but a discussion group.
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: headware |
last post by:
I have a <select> control that contains many entries. It allows the
user to multi-select a group of them, click a button, and store the
selected data in a database. Normally they do this starting...
|
by: relaxedrob |
last post by:
Hi All,
I want to write a select control and use a Javascript function to
handle all click events on the control. Under certain circumstances I
also wish to prevent the dropdown's list from...
|
by: jascraig |
last post by:
Here's my dilemma. I'm working with a frameset with 3 frames
(header,content,control). My control frame contains a select list with
buttons for next and previous. When the next button is pushed...
|
by: larry |
last post by:
Hi,
I am a newbie to Internet programming. I have some questions about
spacing in HTML control names and subsequently being able to access
these input elements in JavaScript If you don't have...
|
by: Allan M. |
last post by:
I have a series of select boxes that must be populated
client side, because they interact with each other. The
design specification calls for these boxes to be updated
without having to make a...
|
by: Mad Scientist Jr |
last post by:
I'm stuck trying to work with a HTML <SELECT> control and javascript
(similar to DualList but that control doesn't offer enough options to
totally control the text on the buttons and control, also...
|
by: Chris Fink |
last post by:
Does anyone know it is possible to include a small image(.gif .jpeg)
within a <SELECT><option> so that the user would see the option text as
well as a little image(icon) in the option? I know this...
|
by: frank.sconzo |
last post by:
Greetings,
I was testing my web application on the Mac/Safari and noticed a
problem with the background color of the select input element.
Safari doesn't seem to pay any attention to the style I...
|
by: simon.wilkinson |
last post by:
Hi,
I am trying to update all Select boxes on a page dynamically using
javascript, I simple want to change the selected item in each select
box when a tick box is pressed on the page. Each...
|
by: andypb123 |
last post by:
Hello,
The onchange event fires in IE6 in a SELECT element when scrolling
through the list with the up and down arrows on the keyboard. In
Firefox it only fires after you hit the enter key, which...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
| |