473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Multiple drop-down selectors -- please HELP !

Hello,

I have no java experience and need to know how to make four drop-down
lists,
with the selections in each list dependent on a selection made in the
prior
list. As an alternate, something similar to the category selector
found on
the eBay sell items webpage. Could anyone please send me the code on
how to do this or point me to some freeware / shareware applet ?

Thanks in advance!
Jul 23 '05 #1
5 1182
This does it more or less. You'll have to write the rest yourself, but the
code is identical for the other lists, except for the values of course ;-)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Listbox generator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">

function generateListBox2(intSelectedValue)
{
var strHTML;

strHTML = "<select onChange='generateListbox3(this.selectedIndex+1)'
size='4'>";

switch(intSelectedValue) {

case 1:
strHTML = strHTML + "<option>PARIS</option>";
strHTML = strHTML + "<option>TOULOUSE</option>";
strHTML = strHTML + "<option>CANNES</option>";
strHTML = strHTML + "<option>NICE</option>";
break;
case 2:
strHTML = strHTML + "<option>BRUSSELS</option>";
strHTML = strHTML + "<option>ANTWERP</option>";
strHTML = strHTML + "<option>GHENT</option>";
strHTML = strHTML + "<option>BRUGES</option>";
break;
case 3:
strHTML = strHTML + "<option>ROME</option>";
strHTML = strHTML + "<option>PISA</option>";
strHTML = strHTML + "<option>FLORENCE</option>";
strHTML = strHTML + "<option>MANTUA</option>";
break;
case 4:
strHTML = strHTML + "<option>BARCELONA</option>";
strHTML = strHTML + "<option>MADRID</option>";
strHTML = strHTML + "<option>GRANADA</option>";
strHTML = strHTML + "<option>SEVILLE</option>";
break;
}

strHTML = strHTML + "</select>";

document.getElementById("list2").innerHTML = strHTML;
}

function generateListBox3(intSelectedValue)
{
//same stuff
}

</script>
</head>

<body>
<div id="list1">
<select onChange="generateListBox2(this.selectedIndex+1)" size="4">
<option>FRANCE</option>
<option>BELGIUM</option>
<option>ITALY</option>
<option>SPAIN</option>
</select>
</div>

<div id="list2"></div>

<div id="list3"></div>

<div id="list4"></div>

</body>
</html>
Jul 23 '05 #2
Hi,

Thanks! works well with two menus, but I tried a third one (so
generateListBox3), and it does not get thru. What is wrong here ???

thanks.

<html>
<head>
<title>Listbox generator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function generateListBox2(intSelectedValue)
{
var strHTML;

strHTML = "<select onChange='generateListbox3(this.selectedIndex+1)'
size='4'>";

switch(intSelectedValue) {

case 1:
strHTML = strHTML + "<option>paris</option>";
strHTML = strHTML + "<option>toulouse</option>";
strHTML = strHTML + "<option>cannes</option>";
strHTML = strHTML + "<option>nice</option>";
break;
case 2:
strHTML = strHTML + "<option>brussels</option>";
strHTML = strHTML + "<option>antwerp</option>";
strHTML = strHTML + "<option>ghent</option>";
strHTML = strHTML + "<option>bruges</option>";
break;
case 3:
strHTML = strHTML + "<option>rome</option>";
strHTML = strHTML + "<option>pisa</option>";
strHTML = strHTML + "<option>florence</option>";
strHTML = strHTML + "<option>mantua</option>";
break;
case 4:
strHTML = strHTML + "<option>barcelona</option>";
strHTML = strHTML + "<option>madrid</option>";
strHTML = strHTML + "<option>granada</option>";
strHTML = strHTML + "<option>seville</option>";
break;
}

strHTML = strHTML + "</select>";

document.getElementById("list2").innerHTML = strHTML;
}

function generateListBox3(intSelectedValue)
{

var strHTML;
strHTML = "<select onChange='generateListbox4(this.selectedIndex+1)'
size='4'>";

switch(intSelectedValue) {

case 1:
strHTML = strHTML + "<option>A</option>";
strHTML = strHTML + "<option>B</option>";
strHTML = strHTML + "<option>C</option>";
strHTML = strHTML + "<option>D</option>";
break;
case 2:
strHTML = strHTML + "<option>1</option>";
strHTML = strHTML + "<option>2</option>";
strHTML = strHTML + "<option>3</option>";
strHTML = strHTML + "<option>4</option>";
break;
case 3:
strHTML = strHTML + "<option>H</option>";
strHTML = strHTML + "<option>I</option>";
strHTML = strHTML + "<option>J</option>";
strHTML = strHTML + "<option>K</option>";
break;
case 4:
strHTML = strHTML + "<option>5</option>";
strHTML = strHTML + "<option>6</option>";
strHTML = strHTML + "<option>7</option>";
strHTML = strHTML + "<option>8</option>";
break;
}

strHTML = strHTML + "</select>";

document.getElementById("list3").innerHTML = strHTML;
}

</script>
</head>

<body>
<div id="list1">
<select onChange="generateListBox2(this.selectedIndex+1)" size="4">
<option>france</option>
<option>belgium</option>
<option>italy</option>
<option>spain</option>
</select>
</div>

<div id="list2"></div>

<div id="list3"></div>

<div id="list4"></div>

</body>
</html>
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
BigSister wrote:
Hello,

I have no java experience and need to know how to make four drop-down
lists,
with the selections in each list dependent on a selection made in the
prior
list. As an alternate, something similar to the category selector
found on
the eBay sell items webpage. Could anyone please send me the code on
how to do this or point me to some freeware / shareware applet ?

Thanks in advance!


http://www.mickweb.com/javascript/fo...pleOption.html

This may help.
Mick
Jul 23 '05 #4
Great ! Thanks Mick. This is exactly what I needed. But I am having
problems if I want to use a variable name with a number in it. If I
write, for example:

apple=["macintosh3",...];
macintosh3=[...];
..I get an error. how can this be sorted out ? I really need to use
names with numbers in the menus.

Another question: how can I do so that the empty menus are hidden until
they get filled in with some choice ?

Thanks a lot,

Miguel

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5
Miguel Duran wrote:

apple=["macintosh3",...];
macintosh3=[...];
.I get an error. how can this be sorted out ? I really need to use
names with numbers in the menus.
This shouldn't produce an error, numbers may be used in variable names.
Do you have an example of this failure?
Another question: how can I do so that the empty menus are hidden until
they get filled in with some choice ?


Are you planning to support NN4 browsers? If not, you can set display to
"none":
<select style="display:none" ...>
Then in "createMenu" function:

....
itemArray=eval(mainMenu[mainMenu.selectedIndex].text);
subMenu.length=0;
subMenu.style.display='' ;// or 'inline'

If you want to support NN4, let me know.
Mick

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection...
9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
3
by: rhamlin | last post by:
I'm fairly new to creating complex sql statements and need a little help. In plain english I want to do this: Select menu rows where the row's userGroupIDs equal the user's userGroupIDs. ...
0
by: R. MacDonald | last post by:
Hello, Group, I have an application that contains a large number of controls of a few different types (all custom defined). During certain specific drag-drop operations, I would like to be able...
4
by: pagelogix | last post by:
I'm looking for a way to drop multple tables at the same time from my access database. Any ideas? Thanks.
9
by: sliderip | last post by:
In Access 2003, is it possible to delete multiple tables using a QUERY? I want to delete multiple tables but i guess i cant use wildcards with DROP i..e DROP TABLE mytable1% or something like...
2
by: anchi.chen | last post by:
Hi People, Just wondering if any of you have ever come across any javascript examples that will allow one to drag and drop multiple items between lists? That is, users would be able to use the...
3
by: Hartmut Dippon | last post by:
Hi all, I hope somebody can help me with following problem: I have an application where I can drag&drop files/dirs from within explorer onto my form. If multiple files/dirs are selected I...
0
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vS2005 and .net 2.0. for a Windows application. I'm implementing a Drag and Drop between 2 DataGridView controls. It's working fine with just one item being drag and drop. I want...
2
by: yashgt | last post by:
Script.aculo.us allows only one Draggable to to dropped in a Droppable at a time. Is there a library that allows multiple Draggables to be chosen and dropped? Thanks, Yash
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.