我有这段代码可以创建一个单选按钮,以打开其他单选按钮。我需要重复它,所以我有多个选择,但是每次我这样做时,其他按钮都不起作用。我需要做什么来修复它?这是例子。第二行不扩展。任何帮助将不胜感激。
<!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=UTF-8" />
<title>Sample</title>
</head>
<body>
<script type="text/javascript">
function aff_div(ladiv) {
document.getElementById(ladiv).style.display = "inline";
}
function cach_div(ladiv) {
document.getElementById(ladiv).style.display = "none";
}
function list_one() {
if (document.forms.devis.votconj[0].checked == true) {
aff_div("ssconj");
}
if (document.forms.devis.votconj[1].checked == true) {
document.getElementById("jj").value = 0;
document.getElementById("mm").value = 0;
document.getElementById("aaaa").value = 0;
cach_div("ssconj");
}
if (document.forms.devis.votconjs[0].checked == true) {
aff_div("ssconjs");
}
if (document.forms.devis.votconjs[1].checked == true) {
document.getElementById("jj").value = 0;
document.getElementById("mm").value = 0;
document.getElementById("aaaa").value = 0;
cach_div("ssconjs");
}
}
</script>
<div>
<form id="devis" name="devis" action="Validation-du-formulaire.php" method="post">
<label>SRM</label>
<input type="radio" name="votconj" value="yes" onclick="list_one();">yes
<input type="radio" name="votconj" value="no" checked="checked" onclick="list_one();">no
<div id="ssconj">
<p>
<div>
<form>
<label>Reviewed</label>
<input type="radio" name="gender" value="yes" checked> Yes
<input type="radio" name="gender" value="no"> No
<input type="radio" name="gender" value="NA"> NA
</form>
</div>
</p>
</div>
<script type="text/javascript">
cach_div("ssconj");
</script>
</form>
<form id="devis" name="devis" action="Validation-du-formulaire.php" method="post">
<label>SRM</label>
<input type="radio" name="votconjs" value="yes" onclick="list_one();">yes
<input type="radio" name="votconjs" value="no" checked="checked" onclick="list_one();">no
<div id="ssconjs">
<p>
<div>
<form>
<label>Reviewed</label>
<input type="radio" name="gender" value="yes" checked> Yes
<input type="radio" name="gender" value="no"> No
<input type="radio" name="gender" value="NA"> NA
</form>
</div>
</p>
</div>
<script type="text/javascript">
cach_div("ssconjs");
</script>
</form>
</div>
</body>
</html>