私は単なる初心者です。誰かが私のテーブルからのすべてのテキスト入力の計算結果を反復またはループする手助けをすることができますか?出力は1行にしか表示されず、表の他の行には表示されません。私がこれを解決するのを助けることは、はるかに感謝しています。jQuery/javascriptでeach()を使って反復またはループする方法
<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
私はjavascriptを使用してクライアント側の計算を探しており、入力テキストの計算されたデータを反復処理します。これに関連するアイデアを教えてもらえますか? – jovazel