Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Lists & Combos

Posted on 2000-05-08
2
Medium Priority
?
167 Views
Last Modified: 2013-12-25
Is there a way to filter a combo list based on the selection of another combo list without revisting the server and that works in both IE 4+ and Netscape 4+?



0
Comment
Question by:mshire
[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
2 Comments
 
LVL 8

Accepted Solution

by:
xabi earned 300 total points
ID: 2795707
Here goes an example:

--------- 8< --------- 8< ----------
<html>
<head>
<title>Example</title>
<script language="javascript">
<!--
var aOptions = new Array()
aOptions["1_"]     = "Fruit"
aOptions["1_1_"]   = "Fruit Orange"
aOptions["1_2_"]   = "Fruit Apple"
aOptions["1_1_1_"] = "Fruit Orange Good"
aOptions["1_1_2_"] = "Fruit Orange Bad"
aOptions["1_2_1_"] = "Fruit Apple Green"
aOptions["1_2_2_"] = "Fruit Apple Red"
aOptions["1_2_3_"] = "Fruit Apple Yellow"

aOptions["2_"]     = "Color"
aOptions["2_1_"]   = "Color Red"
aOptions["2_2_"]   = "Color Blue"
aOptions["3_3_"]   = "Color Green"
aOptions["2_1_1_"] = "Color Red Dark"
aOptions["2_1_2_"] = "Color Red Light"
aOptions["2_2_1_"] = "Color Blue Dark"
aOptions["2_2_2_"] = "Color Blue Light"
aOptions["2_3_1_"] = "Color Green Dark"
aOptions["2_3_2_"] = "Color Green Light"

aOptions["3_"]     = "Number"
aOptions["3_1_"]   = "Number Big"
aOptions["3_2_"]   = "Number Small"
aOptions["3_1_1_"] = "Number Big 1000"
aOptions["3_1_2_"] = "Number Big 2000"
aOptions["3_1_3_"] = "Number Big 3000"
aOptions["3_2_1_"] = "Number Small 2"
aOptions["3_2_2_"] = "Number Small 5"
aOptions["3_2_3_"] = "Number Small 9"

function level(sTmp) {
 iTmp = 0
 for (i=0; i<sTmp.length; i++) {
  if (sTmp.charAt(i) == "_") iTmp++
 }
 return iTmp
}

function redo_level3() {
 idselect = document.myform.myselect3
 idselect.length = 0
 if (document.myform.myselect2.selectedIndex != -1) {
  sTmp = document.myform.myselect2.options[document.myform.myselect2.selectedIndex].value
 } else {
  if (document.myform.myselect1.selectedIndex != -1) {
   sTmp = document.myform.myselect1.options[document.myform.myselect1.selectedIndex].value
  } else {
   sTmp = ""
  }
 }
 for (sName in aOptions) {
  if ((level(sName) == 3) && (sName.substr(0,sTmp.length) == sTmp)) {
   idselect.length++
   idselect.options[idselect.length-1].value = sName
   idselect.options[idselect.length-1].text  = aOptions[sName]
  }
 }
}

function redo_level2() {
 idselect = document.myform.myselect2
 idselect.length = 0
 if (document.myform.myselect1.selectedIndex != -1) {
  sTmp = document.myform.myselect1.options[document.myform.myselect1.selectedIndex].value
 } else {
  sTmp = ""
 }
 for (sName in aOptions) {
  if ((level(sName) == 2) && (sName.substr(0,sTmp.length) == sTmp)) {
   idselect.length++
   idselect.options[idselect.length-1].value = sName
   idselect.options[idselect.length-1].text  = aOptions[sName]
  }
 }
 redo_level3()
}

function redo_level1() {
 idselect = document.myform.myselect1
 idselect.length = 0
 for (sName in aOptions) {
  if (level(sName) == 1) {
   idselect.length++
   idselect.options[idselect.length-1].value = sName
   idselect.options[idselect.length-1].text  = aOptions[sName]
  }
 }
 redo_level2()
}

//-->
</script>
</head>
<body onload="redo_level1()">
 <form name="myform">
  <select name="myselect1" size="4" onchange="redo_level2()">
  <option>--------------------------------------------------------------</option>
  </select>
  <br><br>
  <select name="myselect2" size="4" onchange="redo_level3()">
  <option>--------------------------------------------------------------</option>
  </select>
  <br><br>
  <select name="myselect3" size="4">
  <option>--------------------------------------------------------------</option>
  </select>
 </form>
</body>
</html>
---------- 8< ----------- 8< ---------

If you need more info just ask.

xabi
0
 

Author Comment

by:mshire
ID: 2799736
With a little alteration, I managed to get it to work the way I wanted... I've just got to try it out on Netscape. Thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

610 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