我创建了一个简单的表格,我想充当一个网络计算器,其中的总数将是按照小提琴插入的列中值的总和。我怎样才能实现,以便我可以用表格实际计算?
主页:
<h1> Calculator</h1>
<b>Step 1:</b> Click the "Calculate" button to find your purchase cost.
<br>
<b>Step 2:</b> Print this page for your records.
<br>
<p class="margin_top">
<input type="submit" value="Calculate">
<table cellpadding="1" cellspacing="0" border="0">
<tr>
<td class="header">Item</td>
<td class="header"></td>
<td class="header">Include</td>
<td class="header"></td>
<td class="header"></td>
<td class="header">Actual Amount</td>
<td class="header"></td>
</tr>
<tr>
<td valign="middle">Facility Rental</td>
<td></td>
<td valign="middle" align="center">
<input type="checkbox" name="item0" value="6" unchecked>
</td>
<td></td>
<td valign="middle">$</td>
<td valign="middle" align="left">
<input type="text" name="Ramount[]" value="" size="10">
</td>
<td></td>
<td valign="middle" align="left">$ 0</td>
</tr>
<tr>
<td valign="middle">Officiant</td>
<td></td>
<td valign="middle" align="center">
<input type="checkbox" name="item1" value="1" unchecked>
</td>
<td></td>
<td valign="middle">$</td>
<td valign="middle" align="left">
<input type="text" name="Ramount[]" value="" size="10">
</td>
<td></td>
<td valign="middle" align="left">$ 0</td>
</tr>
<tr>
<td align="right">Total: </td>
<td></td>
<td>$ 0</td>
</tr>
PHP:
<?php
if (isset($_POST['item0'])) $item0 = $_POST['item0'];
if (isset($_POST['item1'])) $item1 = $_POST['item1'];
if (isset($_POST['valuec'])) $valuec = $_POST['valuec'];
$answer = $valuea + $valueb;