如何在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+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=100&width=150&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>
最佳答案
<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>
希望这个能对您有所帮助 :)