1

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

当我下载 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>   
4

1 回答 1

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>

希望对你有帮助 :)

于 2013-06-27T07:46:56.500 回答