2

我有一个使用 div 调用 PHP 文件的 Javascript。这通常工作正常。我正在通过向我的表格添加样式来处理我的网页的外观,这似乎破坏了 div。

这是我的Javascript:

<script type="text/javascript">
function getNextcheck(str)
{
if (str=="")
  {
  document.getElementById("checkno").innerHTML="";
return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("checkno").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getnextcheck.php?id="+str,true);
xmlhttp.send();
}
window.onload = function() {
document.getElementsByName('ID')[0].onchange();
}
</script>

这是网站的html:

<form id="payBills" method="POST" action="">
<br /><table style="border-collapse:collapse; ">
<tr><th style="padding-left:4px; border:1px solid #dddddd; background-color:#efefef; color:black;" width="50">Select</th><th style="padding-left:4px; border:1px solid #dddddd; background-color:#efefef; color:black;" width="165">Bank</th><th style="padding-left:4px; border:1px solid #dddddd; background-color:#efefef; color:black;" width="185">Account Number</th><th style="padding-left:4px; border:1px solid #dddddd; background-color:#efefef; color:black;" width="150">Current Balance</th></tr>

<?php

$i=0;
while($row2 = mysql_fetch_array($result2)) {
$id = $row2['ID'];
$checked = $i?'':'checked';

echo "<tr><td style=\"padding-left:16px; border:1px solid #dddddd;\"><input type=\"radio\" name=\"ID\" value=\"".$row2['ID']."\" {$checked}></td><td style=\"padding-left:4px; border:1px solid #dddddd;\">".$row2['name']."</td><td style=\"padding-left:4px; border:1px solid #dddddd;\">".$row2['acctnum']."</td>";
$i=1;

$result7 = mysql_query("SELECT SUM(deposit), SUM(withdrawal) FROM bankaccount_transaction WHERE bankaccount_id = '$id'") or die(mysql_error());
$row7 = mysql_fetch_array($result7);
$deposit = $row7['SUM(deposit)'];
$withdrawal = $row7['SUM(withdrawal)'];

$total = $deposit - $withdrawal;
$newtotal = number_format($total,2);

echo "<td style=\"padding-left:4px; border:1px solid #dddddd;\">$".$newtotal."</td></tr>";

}
?>

</table>
<br />
<div id="checkno"></div>
<br /><br />
<input type="submit" name="submit" value="Pay" />
</form>

无论如何,我尝试用 span 代替 div ,但这也不起作用。

4

1 回答 1

0

我不明白这个标签:

{$checked}

为什么不使用它:

... ".$checked." ...
于 2013-05-25T16:47:35.970 回答