combo_box和radio_button [英] combo_box and radio_button

查看:84
本文介绍了combo_box和radio_button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javascript:confused :: confused:中有问题:
我有三个单选按钮,父亲,母亲,孩子和一个组合框.
在选择父亲(单选按钮)时,组合框将给出f1,f2,f3,f4,f5的列表
在母亲身上,它显示了m1,m2,m3,m4,m5,m6,m7,m8
还有孩子,k1,k2,k3
谁能给我一个Javascript来解决这个问题.....

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.....

推荐答案



在下面找到可帮助您解决问题的html代码

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>



希望这项工作对您有用

谢谢
Mehul Thakkar



Hope this work for you

Thanks
Mehul Thakkar


好...那么,实际的问题是什么?
Ok... So, what''s the actual problem?


这篇关于combo_box和radio_button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆