日期:2014-05-16  浏览次数:20482 次

JS 单选框选择动态数据
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Untitled Document</title>
		<script>
			function query()
			{
				var checked = document.getElementsByName("radiotest");
				var inputValue;
				for(var i = 0;i < checked.length;i++)
				{
					if(checked[i].checked)
					{
						inputValue = document.getElementById(checked[i].value);
						alert(inputValue.value);
					}
				}
			}			
		</script>
	</head>
	<body>
		<input type="radio" value="test1" name="radiotest"/><input type="text" id="test1" name="test1"/><br>
		<input type="radio" value="test2" name="radiotest"/><input type="text" id="test2" name="test2"/><br>
		<input type="button" value="click" onclick="query();"/>
	</body>
</html>
?