0

so far I got this, the changing of text will appear on input text. I want just put it as span/label.

<script>
function pros(frm){
      //For each checkbox see if it has been checked, record the value.
   for (i = 0; i < frm.box.length; i++)
      if (frm.box[i].checked){
         frm.text[i].value = 'Checked';
      } else {
    frm.text[i].value = 'Unchecked';
      }

}
</script>

and the HTML is

<form method="post" action="field/check.php" name="field">
    <table class='zb'>

<tr><td><b>Reading</b></td><td><input type='checkbox' id='box' name='Reading' value='Reading' onchange='pros(this.form)'/></td>
<td><input type='text' class='nobord' id='text' value='Unchecked' readonly></td></tr>
<tr><td><b>Grammar</b></td>
<td><input type='checkbox' id='box' name='Grammar' value='Grammar' onchange='pros(this.form)'/></td>
<td><input type='text' class='nobord' id='text' value='Unchecked' readonly></td></tr>
<tr><td><b>Writing</b></td>
<td><input type='checkbox' id='box' name='Writing' value='Writing' onchange='pros(this.form)'/></td>
<td><input type='text' class='nobord' id='text' value='Unchecked' readonly></td></tr>
<tr><td><b>Speaking</b></td>
<td><input type='checkbox' id='box' name='Speaking' value='Speaking' onchange='pros(this.form)'/></td>
<td><input type='text' class='nobord' id='text' value='Unchecked' readonly></td></tr>   
        </table><br/>
    <div align="center">
<input type="submit" name="Submit" value="Submit" class="cssbutton"/>  
<input name="reset" type="reset" value="Reset" class="cssbutton"/>

</form>

so, how the JS to put the result on span/label (if checked or unchecked)? then I will put span/label somewhere after tag form closed.

user3067476
  • 37
  • 1
  • 6
  • So where those label/span in your example ? – zb' Dec 04 '13 at 20:54
  • could be after tag form is closed. – user3067476 Dec 05 '13 at 03:26
  • ***1*** add a span with the id of resultSpan. ***2*** change instances of `frm.text[i].value` to `document.getElementById('resultSpan').innerHTML`. I've assumed a single span, though your code appears to indicate several. In that case, ***1*** add 4 spans, with ids of `resultSpan0` to `resultSpan3` ***2*** Change instances of `frm.text[i].value` to `document.getElementById('resultSpan'+i).innerHTML` – enhzflep Dec 05 '13 at 03:55

0 Answers0