如何在多个复选框上调用javascript函数在php中单击?

时间:2013-06-27 07:40:26

标签: php javascript html5

如何在多个复选框上调用javascript函数点击php?

当我下载excel时,它不会获取所选的值。

<script>
function xls_fun()
{ 
        alert('hi');
        var code=document.getElementById('code').value; 
        var hpnm=document.getElementById('hpnm').value;     
        var d_add=document.getElementById('d_add').value;


    document.getElementById('xls_link').href="createxls.php?fnm=mynewxls.xls&code="+code+"&hpnm="+hpnm+"&d_add="+d_add+"&amp;placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=100&amp;width=150&amp;modal=false";
        }
</script>
      <tr><th align="center">Code Number</th><th align="center">Name Of Hospital</th>
    <th align="center">Doctor Address</th></tr>

       <tr><td><?php echo $row1['code'];?></td><td><?php echo $row1['hname'];?></td>
        <td><?php echo $row1['doc_add'];?></td></tr>

       <tr><th align="center"><th align="center"><input type="checkbox" name="code" id="code" value="<?php echo $row1['code'];?>" onchange="xls_fun()"></th>    
          <th align="center"><input type="checkbox" name="hpnm" id="hpnm" value="<?php echo $row1['hname'];?>" onchange="xls_fun()"></th>
          <th align="center"><input type="checkbox" name="d_add" id="d_add" value="<?php echo $row1['doc_add'];?>" onchange="xls_fun()"></th>   

1 个答案:

答案 0 :(得分:0)

<script>
function checkall(objForm)
{
    len = objForm.elements.length;
    var i=0;
    for( i=0 ; i<len ; i++){
    if (objForm.elements[i].type=='checkbox') 
        objForm.elements[i].checked=objForm.check_all.checked;
     }
     frmobj.what.value="Delete";
     frmobj.action = "books/delete";
     frmobj.submit();
}
</script>
<th><input name="check_all" type="checkbox"   id="check_all" onclick="checkall(this.form)" value="check_all" /></th>

希望这会对你有所帮助:)。