【问题标题】:radio button form to print text单选按钮表单打印文本
【发布时间】:2015-07-03 13:48:23
【问题描述】:

帮助。我不是程序员,而是历史学家。我正在尝试创建一个单选按钮表单,以便当我单击不同子组中的表单按钮,然后点击提交时,我会得到一个包含单选按钮选择文本的文本框。

这是我目前所拥有的。我需要的是允许打印的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>

【问题讨论】:

    标签: forms button radio


    【解决方案1】:

    这应该对你有帮助

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

    【讨论】:

    • 谢谢。这很有帮助。如何让文本框变大?
    • 它几乎可以工作了。当我点击单选按钮并点击“提交”时,会显示“论文”下的完整声明(例如:论文很清楚),但下一行只有“简介。所以,有一个不需要的”,只有第一个词.嗯。
    • 您可以在大多数浏览器(如 Chrome 和 Firefox)中根据需要扩展文本区域。文本将按预期显示。检查此jsfiddle.net/h4mtsyh2
    • 问题不在于文本区域的大小。问题是并非所有文本都显示出来。我无法显示图片,但这是点击提交后的样子: Thesis is clear [next line] “Introduction 好吧,那一行应该比简单的 Introduction 更多。这有意义吗?
    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    相关资源
    最近更新 更多