By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

dynamic drop-menu content?

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.


"LRW" <de**@celticbear.com> wrote in message
news:3a**************************@posting.google.c om...
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

Jul 23 '05 #2

P: n/a
LRW wrote:
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,

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.