PDA

View Full Version : Creating new set of dropdown menus on selection



sudhakararaog
Sep 19th, 2007, 05:47 AM
when an option is choosen from a dropdown list using select tag and based on which option was selected How to create a new set of dropdown menu just beside the original dropdown list.

Also from this new drop down that a user selects how can this value be passed to a php file in order to read which value was chosen from the newly creted drop down menu.

please advice

Fang
Sep 19th, 2007, 08:36 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>change 2nd select</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
var varieties=[
["varieties","granny smith","golden delicious","jonathan"],
["varieties","anjou","bartlett","conference"],
["varieties","valencia","pineapple","pera"]
];

function Box2(idx) {
var f=document.myform;
f.box2.options.length=null;
for(i=0; i<varieties[idx].length; i++) {
f.box2.options[i]=new Option(varieties[idx][i], i);
}
}
window.onload=function(){Box2(0);};
</script>

<style type="text/css">

</style>

</head>
<body>
<form name="myform" method="post" action="http://www.mysite.com/mysite">
<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>


The form name/value pairs will be passed to the action URL in the form, in the normal way.