1

我在 3 个框架集中的一个框架内有 10 个复选框。

<frameset cols="16%,68%,16%">
    <frame src="fish.html" name="bodyleft" noresize scrolling=no>
    <frame src="fish1.html" name="bodymid" noresize scrolling=no>
    <frame src="fish2.html" name="bodyright" noresize scrolling=no>
    </frameset>

fish1.html 上的代码

<script type="text/javascript">
  function countCheckboxes ( ) 
  {
    var form = document.getElementById('testForm');
    var count = 0;
    for(var n=0;n < form.length;n++)
    {
      if(form[n].name == 'items[]' && form[n].checked)
      {
        count++;
      }
    }
    document.getElementById('checkCount').innerHTML = count;
  }
  window.onload = countCheckboxes;
</script>

是否可以计算fish2.html而不是fish1上选中复选框的数量?我怎么做?

4

1 回答 1

0

尝试这样的事情(尚未测试):

var frame2 = document.getElementById('bodyright');
window.onload = countCheckboxes(frame2);
function countCheckboxes (frame) 
{
   var forms = frame.document.getElementsByTagName('form');
   //...
}
于 2013-03-05T13:46:46.963 回答