Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I hav an problem in javascript:confused::confused:
I have three radio button father, mother, kid and ONE combo box.
On selection of father(radio button), combo box gives list of f1,f2,f3,f4,f5
and on mother, it shows m1,m2,m3,m4,m5,m6,m7,m8
and on kid, k1,k2,k3
can any body give me the javascript to solve this.....
Posted
Updated 12-Jan-10 19:06pm
v2

Hi,

Find the html code below which will help you to resolve your problem

<html>
	<script language="javascript">

function ShowItems(val, items) {
    
    var arrValues = eval(items);
    var item;
    var length = document.getElementById("combo").options.length;
    for (var i = 1; i < length; i++)
        document.getElementById("combo").options.remove(1);
    
    for (var i = 0; i < arrValues.length; i++) {
    item = document.createElement("option");
    item.text = arrValues[i];
    item.value = arrValues[i];
    document.getElementById("combo").options.add(item);
    }
}
</script>

<div align="center">
<form name="form1">
<input type="radio" id="f" value="f" name="r" onclick="ShowItems('f','[\'f1\',\'f2\',\'f3\',\'f4\',\'f5\']')" />Father
<input type="radio" id="m" value="m" name="r" onclick="ShowItems('f','[\'m1\',\'m2\',\'m3\',\'m4\',\'m5\',\'m6\',\'m7\',\'m8\']')"/>Mother
<input type="radio" id="k" value="k" name="r" onclick="ShowItems('f','[\'k1\',\'k2\',\'k3\']')"/>Kid
<select id="combo">
    <option>--Select--</option>
</select>

</form>
</div>
</html>


Hope this work for you

Thanks
Mehul Thakkar
 
Share this answer
 
Ok... So, what's the actual problem?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900