dynamic drop-menu content?

L

LRW

I've a page where I have two form drop-menu. I need the second menu to
populate only with items based on what's selected in the 1st menu.

I have "Javescript in Easy Steps" and the closest it discusses is
populating list content based on a radio button, but the book is so
badly written, I'm having a horrible time trying to adjust using two
menus.

I did a Google for the sublect, and found
http://www.blazonry.com/javascript/js_menu.php which is easier to
understand, but I still can't get it to work.

All I need is a link to a good Web page that discusses this topic, and
I'll figure it out on my own. If anyone has any Web sites they know
that deal with this?
Thanks!

Liam
 
D

Dominique

two options...

use Arrays for items
or

//-------------start copy
<script language="Javascript">
function getItems(val) {
if (val) { //check that there IS a selection
made
document.getElementById("container").innerHTML =
document.getElementById("item"+val).innerHTML
}
}
</script>

<div id=item1 style="display:none">
<select name=itemsfor1>
<option>11111</option>
<option>11111111</option>
</select>
</div>
<div id=item2 style="display:none">
<select name=itemsfor2>
<option>22222</option>
<option>22222222</option>
</select>
</div>
<div id=item3 style="display:none">
<select name=itemsfor3>
<option>33333</option>
<option>33333333</option>
</select>
</div>

<form name=whateva>
<select name=select1 onchange="getItems(this.value)">
<option value="">Select</option>
<option value=1>Item list 1</option>
<option value=2>Item list 2</option>
<option value=3>Item list 3</option>
</select>


<div id=container></div>

</form>
//--------------------end copy

copy everything AS IS and place it in an html page and test it...

this was rushed, so forgive mistakes...

what you can do then is give each option in the item lists values and/or put
onchange events for those select boxes so that they do something.
 
M

Matt Kruse

LRW said:
I've a page where I have two form drop-menu. I need the second menu to
populate only with items based on what's selected in the 1st menu.

There are a lot of solutions out there, and a lot of them don't work as well
as they could.
Simple solutions that are often posted here work in the simplest
environments and most current browsers, but fail on others.

I have a dynamic option list library which is pretty robust and handles a
lot of features you might need (like default values when the page loads,
handling form reset, etc).
It's at http://www.mattkruse.com/javascript/dynamicoptionlist/

Hope that helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top