• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
罗小亭
博客园    首页    新随笔    联系   管理    订阅  订阅
根据单选框改变的文本框

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312">

<title>网页特效 根据单选框改变的文本框 </title>
<script language="javascript">
<!--
function changeItem(i)
{
var k = 2;
for(var j = 0;j < k;j++){
if(j == i){
document.all["Div" + j].style.display = "block";
}
else{
document.all["Div" + j].style.display = "none";
}
}
}
</script>
</head>
<body>

<input type="radio" name="region" value="1" checked onClick="return changeItem(0);">单选1
<input type="radio" name="region" value="2" onClick="return changeItem(1);">单选2<br>
<div id="Div0" style="display:block;">Item1:<input type="text" name="textfield"></div>
<div id="Div1" style="display:none;">Item2:<input type="text" name="textfield2"></div>
</body>
</html>

posted on 2015-09-27 23:29  罗小亭  阅读(520)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3