当我点击提交按钮时如何将复选框/单选按钮发布到textarea?

时间:2015-07-27 16:06:46

标签: javascript html

我希望制作此代码,以便在您单击单选按钮或复选框时,它会在代码底部的注释框中打印?任何人都知道如何将javascript连接到HTML?

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

}
checkbox= document.getElementsByName('Verification');
for (var i = 0, length = checkbox.length; i < length; i++) {
if (checkbox[i].checked) {
    tarea.innerHTML+=checkbox[i].value;


}


var phoneData=document.getElementById('phone1');
tarea.innerHTML+=phoneData.value;

}


</SCRIPT>
</HEAD>
 <b>Contact Tel Number</b> 
<TEXTAREA id="phone1"rows="1"cols="40"></textarea>


<BODY>


<FORM NAME="frmOne">


 <P>
 <input type="checkbox" name="Monitored"value="Monitored">
  <b>Monitored/Recorded Line Disclosure Given?</b>

                            <br>
 <i>All calls are recorded and monitored</i><br><br>


 <tr>
 <td><INPUT TYPE="Radio" Name="thesis" Value="Inbound Call">
 <b>Inbound Call</b><br></td>


 <td><INPUT TYPE="Radio" Name="thesis" Value="Outbound Call"><b>
 Outbound Call</td></td><br>
 <br>

</P>   


<b>Who Called:</b>


<P>
<tr><td>
<INPUT TYPE="Radio" Name="intro" Value="Consumer"Consumer<br>          
<INPUT TYPE="Radio" Name="intro" Value="Co-Borrower">Co-Borrower<br>
<INPUT TYPE="Radio" Name="intro" Value="Attorney">Attorney<br>
<INPUT TYPE="Radio" Name="intro" Value="Wrong Party">Wrong Party<br>
<INPUT TYPE="Radio" Name="intro" Value="Authorized 3rd Party">
 Authorized 3rd Party<br>
<INPUT TYPE="Radio" Name="intro" Value="Power of Attorney">
 Power of Attorney<br>
<INPUT TYPE="Radio" Name="intro" Value="Spouse">Spouse<br>
<INPUT TYPE="Radio" Name="intro" Value="Non-Auth 3P">Non-Auth 3P<br>
<INPUT TYPE="Radio" Name="intro" Value="Wrong Party">
 Wrong Party<br></td></tr>
</P>


<P>What did the Consumer verify?<i> Just use one!</i><br>

<td>

<input type="checkbox" name="Verification" value="Full Address"><b>
 Full Address</b>
</td>

<td>
<input type="checkbox" name="Verification" value="Last 4 of SSN"><b>
Last 4 of SSN</b>
</td>

<td>
<input type="checkbox" name="Verification" value="Wrong Party"><b>
Wrong Party</b>
</td>

 <td>
<input type="checkbox" name="Verification" value="Date of Birth"><b>
Date of Birth</b>
 </td>

<td>
 <input type="checkbox" name="Verification" value="Client Acct#"><b>
 Client Acct#</b>
</td>

</P>
<br>

 Mini-Miranda Given? <br>

 <i>
 I must inform you that this communication is an attempt to collect a debt    by a debt collector. 
Any information obtained will be used for that purpose. </i>



<table border="2" style="width:100%">

     如果获得许可,请输入电话号码:

<br>

  <input type="text" name="" size="75" style="background-color:Yellow">

  <p align="Center"><b>Reason for Delinquency:</b>
<br>

  <input type="text" name="" size="75" style="background-color:Yellow">
 <p align="Center"><b>Payment Options Offered:</b>

 <br>

  <input type="text" name="" size="75" style="background-color:Yellow"><br>
                            </table><br>

<table border="2" style="width:100%" align="center">

                                <p align="Center"><b>Next Step:</b>

                                </p>

                                <td>

  <input type="checkbox" name="
  Payment Terms Accepted"value="FullAddress"><b>
  Payment Terms Accepted</b>

 <br>

  <input type="checkbox" name="Set Up Call Back " value=
  "Set Up Call Back"><b>Set Up Call Back</b>

  <br>

  <input type="checkbox" name="Caller Request CAD" value="
  Caller Request  CAD"><b>Caller Request CAD</b>

 <br>

  <input type="checkbox" name="Requested Mail Only" value="
  Requested Mail Only"><b>Requested Mail Only</b>

 <br>

  <input type="checkbox" name="Requested Letter" value="
  Requested Letter"><b>Requested Letter</b>

 <br>

  <input type="checkbox" name="Conf/Warm Transfer to AES" value="
  Conf/Warm Transfer to AES"><b>Conf/Warm Transfer to AES</b>

 <br>
  <input type="checkbox" name="
  Refer to AES/Unable to Transfer" value="
  Refer to AES/Unable to Transfer"><b>Refer to AES/Unable to Transfer</b>

 <br>

   <input type="checkbox" name="Borrower Deceased" value="
   Borrower Deceased"><b>Borrower Deceased</b>

   <br>

    <input type="checkbox" name="DIS/VOD Request" value="
    DIS/VOD Request"><b>DIS/VOD Request</b>

                                    </th>
 <br>

                                    <th align="left">

     <input type="checkbox" name="Refused all Options" value="
      Refused all Options"><b>Refused all Options</b>

 <br>

     <input type="checkbox" name="Going Out To Raise Funds" value="
     Going Out To Raise Funds"><b>Going Out To Raise Funds</b>

 <br>

     <input type="checkbox" name="Caller Hung Up" value="
      Caller Hung Up"><b>Caller Hung Up</b>

 <br>

      <input type="checkbox" name="Customer Filing BKY" value="
       Customer Filing BKY"><b>Customer Filing BKY</b>

 <br>

      <input type="checkbox" name="Co-Maker Filing BKY" value="
      Co-Maker Filing BKY"><b>Co-Maker Filing BKY</b>

 <br>

      <input type="checkbox" name="Active Duty Military" value="
      Active Duty Military"><b>Active Duty Military</b>

 <br>

      <input type="checkbox" name="
       Account No Longer With NGI" value="Account No Longer With NGI"><b>
       Account No Longer With NGI</b>

  <br>

      <input type="checkbox" name="Claims Fraud" value="
      Claims Fraud"><b>Claims Fraud</b>

    <br>

      <input type="checkbox" name="RET/DECL Follow Up" value="
       RET/DECL Follow Up"><b>RET/DECL Follow Up</b>
                                </td>
                                </th>
                                </tr>

     <br><br>

                            </table>

      <br>

      <center><INPUT TYPE="button" VALUE="  SUBMIT  " onClick="validate()">

      </FORM>
   <br>
   <br>

  Call Details:

  <TEXTAREA id="ta"rows="10" cols="90"></textarea>
  </BODY>

1 个答案:

答案 0 :(得分:0)

设置复选框的onclick事件以切换textarea

<input type="checkbox" name="Going Out To Raise Funds" value="Going Out To Raise Funds"
     onclick="document.getElementById('ta').value = this.checked ? document.getElementById('checkboxid').name : ''"
id="checkboxid"><b>Going Out To Raise Funds</b></input>

<textarea id="ta"rows="10" cols="90"></textarea>