Ah thanks, thats great, but!
How can I adapt this so that when something on the second menu is selected it fills a text box with information.
I.e The first list is categories, the second list is products, and then a text box with info about the selected product.
Any ideas how to do this?
Many thanks
Code:
<script>
var store = new Array();
store[0] = new Array(
'PJP100','',
'PJP120','',
'PJP200FC','',
'PJP200F');
store[1] = new Array(
'Web Designer\'s Forum',
'http://www.wdf.net',
'CSS1 Mastergrid',
'http://webreview.com/wr/pub/guides/style/mastergrid.html');
store[2] = new Array(
'Stefan Koch\'s JavaScript Tutorial',
'http://rummelplatz.uni-mannheim.de/~skoch/js/tutorial.htm',
'Client Side JavaScript Reference',
'http://developer.netscape.com/docs/manuals/js/client/jsref/index.htm',
'Web Designer\'s Forum',
'http://www.wdf.net');
function init()
{
optionTest = true;
lgth = document.forms[0].second.options.length - 1;
document.forms[0].second.options[lgth] = null;
if (document.forms[0].second.options[lgth]) optionTest = false;
}
function populate()
{
if (!optionTest) return;
var box = document.forms[0].first;
var number = box.options[box.selectedIndex].value;
if (!number) return;
var list = store[number];
var box2 = document.forms[0].second;
box2.options.length = 0;
for(i=0;i<list.length;i+=2)
{
box2.options[i/2] = new Option(list[i],list[i+1]);
}
}
</script>
</head>
<BODY onLoad="init()">
<form action="#">
<select name="first" onchange="populate()"><option>Please select paper type</option><option value="0">Professional Proofing</option><option value="1">Contract Proofing</option><option value="2">Architectural/CAD</option><option value="3">Fine Art Media</option><option value="4">Display Graphic Media</option></select>
<br>
<select name="second" onchange="go()"><option value="http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/">Client Side JavaScript Reference</option><option value="http://www.evolt.org">Evolt</option></select>
</form>
</body>
Bookmarks