我使用此代码而其他td具有相同的showDetails代码
echo '<td width=25 onclick="toggleSlijtd('.$row['id'].')"><img title="'.htmlentities($lang['slijtdeel_minus']).'" src="images/icon/arrow_minus.png"></td>
<td width=25 align="right" onclick="setHighlighted(this),showDetails('.$row['id'].');">'.$row['aantal_huidig'].'</td>';
showDetails使面板显示更多信息,toggleSlijtd使数字减少一个。他们正在努力但是:
我的代码出了什么问题?或者我应该完全使用其他代码。我希望不是因为时间不多了。
我的Ajax脚本:
var xmlhttp;
var hold_rowid="";
function toggleSlijtd(str)
{
hold_rowid=str;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="includes/js/ajax_toggle_slijtdeel.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("row"+hold_rowid).innerHTML=xmlhttp.responseText; //this now identifies which cell to target and change.
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
php文件:
mysql_select_db($database, $con);
$id = $_GET["q"];
$sql = "SELECT aantal_huidig FROM slijtdelen WHERE id = '".$id."' ";
$query = mysql_query($sql, $con) or die(mysql_error());
// Verminder hoeveelheid
while($myrow = mysql_fetch_assoc($query))
{
$hoeveelheid = ($myrow['aantal_huidig'] - 1);
}
$sql="UPDATE slijtdelen SET aantal_huidig = '".$hoeveelheid."' WHERE id = '".$id."' ";
$query = mysql_query($sql, $con) or die(mysql_error());
// Stuur wel of geen icoon terug
if($hoeveelheid > 0)
{
echo '<td width=25 onclick="toggleSlijtd('.$row['id'].')"><img title="'.htmlentities($lang['slijtdeel_minus']).'" src="images/icon/arrow_minus.png"></td>
<td width=25 align="right">'.$hoeveelheid.'</td>';
}
else
{
echo '';
}
?>
呈现页面:
</table><table id="top_header" cellspacing="0" cellpadding="0" width="100%">
<tr class="top_table floating header">
<td width=10 class="top_table_start"></td>
<td width=100>Bestelnr. <a href="/slijtdelen.php?sort_name=slt.bestelnummer&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=slt.bestelnummer&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=350>Omschrijving <a href="/slijtdelen.php?sort_name=slt.omschrijving&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=slt.omschrijving&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=100 colspan="3">Voorraad <a href="/slijtdelen.php?sort_name=slt.aantal_huidig&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=slt.aantal_huidig&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=100 colspan="2">In bestelling <a href="/slijtdelen.php?sort_name=slt.in_bestelling&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=slt.in_bestelling&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=125 colspan="2">Prijs per stuk <a href="/slijtdelen.php?sort_name=slt.prijs &sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=slt.prijs &sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=150>Catagorie <a href="/slijtdelen.php?sort_name=cat.catagorie&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=cat.catagorie&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=150>Leverancier <a href="/slijtdelen.php?sort_name=adr.klantnaam&sort=asc" title="Sorteer oplopend"><img src="images/icon/asc.png" ></a> <a href="/slijtdelen.php?sort_name=adr.klantnaam&sort=desc" title="Sorteer aflopend"><img src="images/icon/desc.png" ></a></td>
<td width=10 class="top_table_end"></td>
</tr><tr onMouseOver="addHighlight(this);" onMouseOut="removeHighlight(this);">
<td onclick="setHighlighted(this),showDetails(106);"></td>
<td onclick="setHighlighted(this),showDetails(106);">980SUTA12</td>
<td onclick="setHighlighted(this),showDetails(106);">Boor HSSE PV10 980SUTA Ø12</td><td width=25 onclick="toggleSlijtd(106)"><img title="Haal één uit voorraad" src="images/icon/arrow_minus.png" /></td>
<td width=25 align="right" onclick="setHighlighted(this),showDetails(106);">12</td><td width=50 onclick="setHighlighted(this),showDetails(106);"></td><td width=65 onclick="setHighlighted(this),showDetails(106);"></td><td width=35 onclick="setHighlighted(this),showDetails(106);"></td><td width=75 align="right">€ 21.02</td><td width=50 onclick="setHighlighted(this),showDetails(106);"></td>
<td onclick="setHighlighted(this),showDetails(106);"></td>
<td onclick="setHighlighted(this),showDetails(106);">Heku Tools</td>
<td onclick="setHighlighted(this),showDetails(106);"></td>
</tr>
<tr>
<td colspan="13"> <div id="details106"></div> </td>
</tr><tr onMouseOver="addHighlight(this);" onMouseOut="removeHighlight(this);">
<td onclick="setHighlighted(this),showDetails(104);"></td>
<td onclick="setHighlighted(this),showDetails(104);">980SUTA121</td>
<td onclick="setHighlighted(this),showDetails(104);">Boor HSSE PV10 980SUTA Ø12,1</td><td width=25 onclick="toggleSlijtd(104)"><img title="Haal één uit voorraad" src="images/icon/arrow_minus.png" /></td>
<td width=25 align="right" onclick="setHighlighted(this),showDetails(104);">4</td><td width=50 onclick="setHighlighted(this),showDetails(104);"></td><td width=65 onclick="setHighlighted(this),showDetails(104);"></td><td width=35 onclick="setHighlighted(this),showDetails(104);"></td><td width=75 align="right">€ 39.32</td><td width=50 onclick="setHighlighted(this),showDetails(104);"></td>
<td onclick="setHighlighted(this),showDetails(104);"></td>
<td onclick="setHighlighted(this),showDetails(104);">Heku Tools</td>
<td onclick="setHighlighted(this),showDetails(104);"></td>
</tr>
<tr>
<td colspan="13"> <div id="details104"></div> </td>
</tr><tr onMouseOver="addHighlight(this);" onMouseOut="removeHighlight(this);">
<td onclick="setHighlighted(this),showDetails(105);"></td>
<td onclick="setHighlighted(this),showDetails(105);">980SUTA61</td>
<td onclick="setHighlighted(this),showDetails(105);">Boor HSSE PV10 980SUTA Ø6,1</td><td width=25 onclick="toggleSlijtd(105)"><img title="Haal één uit voorraad" src="images/icon/arrow_minus.png" /></td>
<td width=25 align="right" onclick="setHighlighted(this),showDetails(105);">5</td><td width=50 onclick="setHighlighted(this),showDetails(105);"></td><td width=65 onclick="setHighlighted(this),showDetails(105);"></td><td width=35 onclick="setHighlighted(this),showDetails(105);"></td><td width=75 align="right">€ 16.09</td><td width=50 onclick="setHighlighted(this),showDetails(105);"></td>
<td onclick="setHighlighted(this),showDetails(105);"></td>
<td onclick="setHighlighted(this),showDetails(105);">Heku Tools</td>
<td onclick="setHighlighted(this),showDetails(105);"></td>
</tr>
<tr>
<td colspan="13"> <div id="details105"></div> </td>
</tr></table>
答案 0 :(得分:1)
</tr><tr onMouseOver="addHighlight(this);" onMouseOut="removeHighlight(this);"></td>
以上行</td>
没有任何<td>
。这可能会导致对齐问题。您的服务器端代码不显示此信息。它可能是一个错误的标签。把它作为第一步。