急。如何点击单选按钮后显示文本框?

hsx49949046 2009-08-24 11:24:43
请问下下面这段代码如何实现选中“单先D”后才会显示文本框?选其它单选项的话文本框又会隐藏起来?急。。。先谢过各位大哥了。

单先A<input type="radio" name="radiobutton" value="10" checked>
单先B<input type="radio" name="radiobutton" value="20">
单先C<input type="radio" name="radiobutton" value="30">
单先D<input type="radio" name="radiobutton" value="0">

<input type="text" name="textfield">
...全文
568 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2009-08-24
  • 打赏
  • 举报
回复
单先A <input type="radio" name="radiobutton" value="10" checked onclick="ShowHide(0);">
单先B <input type="radio" name="radiobutton" value="20" onclick="ShowHide(0);">
单先C <input type="radio" name="radiobutton" value="30" onclick="ShowHide(0);">
单先D <input type="radio" name="radiobutton" value="0" onclick="ShowHide(1);">

<input type="text" id=aaa name="textfield" style="display:none">

<script>
function ShowHide(flag){
var o=document.getElementById("aaa");
o.style.display=flag==0?"none":""
}
</script>
shenzhenNBA 2009-08-24
  • 打赏
  • 举报
回复
<input id="textfield" type="text" name="textfield">


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表格属性的操作</title>
</head>
<body>
单先A <input onClick="javascript:xdo(this);" type="radio" name="radiobutton" value="10" checked>
单先B <input onClick="javascript:xdo(this);" type="radio" name="radiobutton" value="20">
单先C <input onClick="javascript:xdo(this);" type="radio" name="radiobutton" value="30">
单先D <input onClick="javascript:xdo(this);" type="radio" name="radiobutton" value="0">

<input id="textfield" type="text" name="textfield">
<script language="javascript" type="text/javascript">
function xdo(obj){
if(obj.value=="0")
document.getElementById("textfield").style.display="block";
else
document.getElementById("textfield").style.display="none";
}
</script>
</body>
</html>
phoeni_xin 2009-08-24
  • 打赏
  • 举报
回复

if(document.all.radiobutton[3].checked){
document.all.textfield.style.display = "block";
}else{
document.all.textfield.style.display = "none";
}

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧