帮助。我不是程序员,而是历史学家。我正在尝试创建一个单选按钮表单,以便当我单击表单的按钮,在不同的子组中,然后点击提交,我会得到一个带有单选按钮选择文本的文本框。
这是我到目前为止所拥有的。我需要的是允许打印的java代码。希望人们可以弄清楚我正在做什么和帮助。
<HTML>
<HEAD>
<TITLE>Paper Comments</TITLE>
<SCRIPT LANGUAGE = "Javascript">
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="frmOne" ACTION="" METHOD="POST">
<P>
<INPUT TYPE="Radio" Name="thesis" Value="thesis4"> Thesis is explicit and clear<br>
<INPUT TYPE="Radio" Name="thesis" Value="thesis3"> Thesis is clear<br>
<INPUT TYPE="Radio" Name="thesis" Value="thesis2">Thesis unclear but decipherable<br>
<INPUT TYPE="Radio" Name="thesis" Value="thesis1"> Thesis is vague<br>
<INPUT TYPE="Radio" Name="thesis" Value="thesis0"> No Thesis<br>
<INPUT TYPE="Radio" Name="thesis" Value="thesisnone"> Answer this question here. The answer would be the thesis.<br>
</P>
<P>
<INPUT TYPE="Radio" Name="intro" Value=“intro4”> Introduction provides direction<br>
<INPUT TYPE="Radio" Name="intro" Value=“intro3”> Introduction provides some direction <br>
<INPUT TYPE="Radio" Name="intro" Value="intro2">Introduction provides little direction<br>
<INPUT TYPE="Radio" Name=“intro” Value="intro1">Introduction provides no direction<br></P>
<INPUT TYPE="button" VALUE=" SUBMIT " onClick="validate()">
</FORM>
</BODY>
</HTML>
答案 0 :(得分:0)
这应该可以帮到你
<HTML>
<HEAD>
<TITLE>Paper Comments</TITLE>
<SCRIPT LANGUAGE = "Javascript">
function validate(){
var radios = document.getElementsByName('thesis');
var tarea=document.getElementById('ta');
for (var i = 0, length = radios.length; i < length; i++) {
if (radios[i].checked) {
tarea.innerHTML=radios[i].value+"\n";
break;
}
}
radios = document.getElementsByName('intro');
for (var i = 0, length = radios.length; i < length; i++) {
if (radios[i].checked) {
tarea.innerHTML+=radios[i].value;
break;
}
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="frmOne">
<P>
<INPUT TYPE="Radio" Name="thesis" Value="Thesis is explicit and clear"> Thesis is explicit and clear<br>
<INPUT TYPE="Radio" Name="thesis" Value="Thesis is clear"> Thesis is clear<br>
<INPUT TYPE="Radio" Name="thesis" Value="Thesis unclear but decipherable">Thesis unclear but decipherable<br>
<INPUT TYPE="Radio" Name="thesis" Value="Thesis is vague"> Thesis is vague<br>
<INPUT TYPE="Radio" Name="thesis" Value="No Thesis"> No Thesis<br>
<INPUT TYPE="Radio" Name="thesis" Value="Answer this question here. The answer would be the thesis."> Answer this question here. The answer would be the thesis.<br>
</P>
<P>
<INPUT TYPE="Radio" Name="intro" Value="Introduction provides direction"> Introduction provides direction<br>
<INPUT TYPE="Radio" Name="intro" Value="Introduction provides some direction"> Introduction provides some direction <br>
<INPUT TYPE="Radio" Name="intro" Value="Introduction provides little direction">Introduction provides little direction<br>
<INPUT TYPE="Radio" Name="intro" Value="Introduction provides no direction">Introduction provides no direction<br></P>
<INPUT TYPE="button" VALUE=" SUBMIT " onClick="validate()">
</FORM>
Your Selection:
<TEXTAREA id="ta"></textarea>
</BODY>
</HTML>