如何从文本框中减去行值

时间:2018-02-13 14:14:26

标签: javascript php html mysql html5

this is the image

例如:

我在其文本框中输入了一个“USED(kl)”的数字,并且将从我在文本框中输入的数字中减去“KILOGRAM / S”的行;

当我点击更新按钮时,它应该只影响它所属的行,而下面的文本框会像SAVE按钮一样受到影响。

以下是代码:

while ($row = mysql_fetch_array($resval))
{

    //  $amount  = $row['amount'] == 0 ? '' : number_format($row['amount']);
    echo '<tr>
        <td name="getit">'.$row['id_raw'].'</td>
        <td>'.$row['prodname'].'</td>
        <td name="getit1">'.$row['kl'].'</td>
        <td>'.$row['ounce'].'</td>
        <td>'.$row['gram'].'</td>
        <td>'.$row['quantity'].'</td>
        <td>'.$row['price'].'</td>
        <td>'.$row['supplier'].'</td>
        <td>'.$row['dateclaim'].'</td>
        <td>'.$row['shelflife'].'</td>
        <td><input step="any" type=number name="aji" style="width:100%;"></td>
        <td><center><input type=submit value="UPDATE" id="button1" name="button1"></center></td>
    </tr>';

这个PHP代码没有用于识别按钮的JavaScript:

if (isset($_POST['a1']) || isset($_POST['a2']) || isset($_POST['a3']) ||  isset($_POST['a4']) ||  isset($_POST['a5']) ||  isset($_POST['a6']) ||  isset($_POST['a7']) ||  isset($_POST['a8']) ||  isset($_POST['a9']) ||  isset($_POST['a10']))

 {
     //Retrieve input from textboxes
//  $SNUM = $_POST['a1'];
$y2 = $_POST['a2'];
$y3 = $_POST['a3'];
$y4 = $_POST['a4'];
$y5 = $_POST['a5'];
$y6 = $_POST['a6'];
$y7 = $_POST['a7'];
$y8 = $_POST['a8'];
$y9 = $_POST['a9'];
$y10 = $_POST['a10'];




//INSERT RECORD To tblregdetails
$sql = "INSERT INTO rawitems values('" . $SNUM . "','" . $y2 . "','" . $y3 . "','" . $y4 . "','" . $y5 . "','" . $y6 . "','" . $y7 . "','" . $y8 . "','" . $y9 . "','" . $y10 . "')";'

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

您不应该在多个元素上拥有相同的ID。我需要看看你的javascript,但只是尝试按类引用按钮

<button type="button" class="cdi-link"><div><span>click to change the arrow</span> <span class="arrow">&#9654;</span></div></button>
<button type="button" class="cdi-link"><div><span>click to change the arrow</span> <span class="arrow">&#9654;</span></div></button>
<button type="button" class="cdi-link"><div><span>click to change the arrow</span> <span class="arrow">&#9654;</span></div></button>