Forum Moderators: open
i m new to javascript
i have created two dropdown menus
in 1st dropdown menu i have Classes options like
class 'A' Hotels
class 'B' Hotels
class 'C' Hotels
required:
if i select class 'A' hotels option then in second dropdown which is hotels dropdown menu should change its items according to its class...
Options for diffrent class of hotels are as follow:
Class 'A' Hotels are:
ROYALTON HOTEL
RUSH INN HOTEL
Class 'B' Hotels are:
ROYAL FALCON HOTEL
SEA SHELL INN
VENDOM PLAZA HOTEL
Class 'C' Hotels are:
GOLDEN TULIP AEROPLANE
HALLMARK
HATTA FORT HOTEL
plz help me....
<script language="javascript">
<!--
function setOptions(chosen)
{
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('first choice - option one','oneone');
selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
}
}
-->
</script>
</head>
<body>
<form name="myform"><div align="center">
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">First Choice</option>
<option value="2">Second Choice</option>
<option value="3">Third Choice</option>
</select><br /> <br />
<select name="opttwo" size="1">
<option value=" " selected="selected">Please select one of the options above first</option>
</select>
<input type="button" name="go" value="Submit">
</div></form>
</body>
</html>
<CREDIT> Credit for this goes to felgall . com javascript tip (had it bookmarked. ) </CREDIT>
Hope this is what you're looking for :0)
--- Zak