faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 16 people (44%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

I have two radio buttons which depending on which one is selected, will populate a dropdown menu.

Apr 7th, 2008 23:41
ha mo, Abolfazl Shirazi, Jay Simmons,


Abolfazl Shirazi:
Try the page below:
<html>
<head>
<script language="javascript">
function MakeEvenNum() {
MyNum = new Array("2","8","14","22","24","32")
for (i=0;i<MyNum.length;i++) {
	NumberList.options[i] = new Option(MyNum[i],MyNum[i]) ;
}
}
function MakeOddNum() {
MyNum = new Array("1","7","13","21","23","31")
for (i=0;i<MyNum.length;i++) {
	NumberList.options[i] = new Option(MyNum[i],MyNum[i]) ;
}
}
</script>
</head>
<body>
<input type="radio" name="ListKind" value="even" onclick="MakeEvenNum
()">Create a List from even numbers<br>
<input type="radio" name="ListKind" value="odd" onclick="MakeOddNum
()">Create a List from odd numbers
<p>
<select name="NumberList" style="width:200">
<option>Select a radio first!</option>
</select>
</body>
</html>
As you see, You just need to substitute your menu items in the 
specific Arrays.
Have Fun.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com