武汉虹信pmp系统:Java脚本的问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/11 01:20:27
我是一个小菜鸟,最近搞个东西玩的时候遇到点问题,请各位帮忙

表单里面有Radio组,当选中其中一个,就刷新页面,并且在旁边显示出一个Select菜单,要怎么做啊?
就比如说,本身页面上只有一组Radio,当我选中其中一个“电脑硬件”的时候,就会刷新页面,并在旁边显示出进一步的详细显示Select菜单!

请各位帮忙,我把我所有的分都献上了
我的意思是,本身那个下拉菜单是隐藏的,当选中某个Radio的时候才显示出来

<script language="javascript">
function check(first,hard,soft)
{
if(first==1)
{
hard.style.display="";
}
else
hard.style.display="none";
if(first==2)
soft.style.display="";
else
soft.style.display="none";
}
</script>
<form id="form1" name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="radio" value="1" onclick="javascript:check(1,yingjian,ruanjian);"/>
硬件</label>
<br />
<label>
<input type="radio" name="radio" value="2" onclick="javascript:check(2,yingjian,ruanjian);"/>
软件</label>
<br />
</p>
<select name="yingjian" style="display:none">
<option value="-1">请选择</option>
<option value="1">cpu</option>
<option value="2">硬盘</option>
<option value="3">i/o</option>
</select>
<select name="ruanjian" style="display:none">
<option value="-1">请选择</option>
<option value="1">操作系统</option>
<option value="2">ie</option>
<option value="3">apache</option>
</select>
</form>
这个是我刚写的代码,测试过了,还能用,你试试看。

在Radio旁边做一个表格td,ID叫select,然后给Radio添加onfocus事件

onfocus="document.getElementById('select').innerHTML='...你的SELECT菜单...'"
onblur="document.getElementById('select').innerHTML=''"

也可以把document.getElementById('select').innerHTML='...你的SELECT菜单...'做成一个function,因为select菜单一行写可能不太好写。

试试吧,我没测试