首页 > 技术文章 > 根据单选框改变的文本框

LuoXiaoTing604404828 2015-09-27 23:29 原文

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

推荐阅读