Click to See Complete Forum and Search --> : Problem with a form


turb
05-12-2004, 08:28 AM
Hi!

here's my situation:

I've got 2 combobox (list) in my form. The first one listed all my product (ex. Car01, Car02, Car03, ...). The second one is for option so if you select Car01, a list of option must be displayed into the second combobox, is you select Car02, another list of option must be displayed, within reloading the page!

Can someone help me to start please?

turb

Fang
05-12-2004, 11:52 AM
This is not the correct forum. JavaScript or DHTML would be more appropriate.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Change selection in one box from another</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
//<![CDATA[
<!--
var varieties=[
["granny smith","golden delicious","jonathan"],
["anjou","bartlett","conference"],
["valencia","pineapple","pera"]
];

function Box2(idx) {
var f=document.myform;
f.box2.options.length=null;
//alert(idx)
for(i=0; i<varieties[idx].length; i++) {
f.box2.options[i]=new Option(varieties[idx][i], i);
}
}
//-->
//]]>
</script>
</head>
<body onload="Box2(0);">
<form name="myform" method="post" action="#">
<select name="box1" onchange="Box2(this.selectedIndex)">
<option value="a">apple</option>
<option value="b">pear</option>
<option value="c">orange</option>
</select>
<select name="box2">

</select>
</form>
</body>
</html>