我只是一個新手。有人可以幫助我迭代或循環從我的表中輸入的所有文本中的計算輸出。輸出顯示但僅在一行中顯示,並且不顯示在表的另一行中。幫助我解決這個問題更值得讚賞。如何迭代或循環使用每個()在jQuery/javascript
<head>
<script language="javascript" type="text/javascript">
function calculateSellingPrice()
{
var txtcost = document.getElementById("cost");
var txtsellingprice = document.getElementById("sellingprice");
var txtprofit = document.getElementById("profit");
//find the total first
var total = parseFloat(txtcost.value) + parseFloat(txtpostage.value);
//for selling price computation
txtsellingprice.value = total;
//for ebay fees computation
if (txtsellingprice.value > 50){
txtebayfees.value = parseFloat(txtsellingprice.value - 50) * 0.05 + 3.5;
}
else if (txtsellingprice.value <= 50){
txtebayfees.value = parseFloat(txtsellingprice.value) * 0.07;
}
}
//-->
</script>
</head>
<body onload="calculateSellingPrice();">
<table>
<tr>
<td><center>SKU</center></td>
<td><center>Selling Price</center></td>
<td><center>Cost</center></td>
</tr>
<?php
$result = mysql_query("SELECT sku, sellingprice FROM tbl_inventory");
while ($myrow = mysql_fetch_row($result))
{
?>
<tr>
<td>
<?php echo "<input type='text' id='sku' name='sku' />"; ?>
</td>
<td>
<?php echo "<input type='text' id='sellingprice' name='sellingprice' />"; ?>
</td>
<td>
<?php echo "<input type='text' id='cost' name='cost' />"; ?>
</td>
</tr>
<?php>
}
?>
</table>
你問如何解決你的PHP模板文件,所以它會輸出到多行?或者你問如何做一些客戶端使用JavaScript?你的問題不清楚如書面。另外,如果你不問一個PHP問題,那麼請發佈瀏覽器看到的生成的javascript(你可以在瀏覽器中使用View/Source來捕獲它),這樣我們就可以看到瀏覽器實際看到的內容。 – jfriend00 2011-12-16 03:18:06