簡體   English   中英

使用post將span值發送到php腳本

[英]Send span value to php script using post

我正在嘗試使用php腳本將數據從表單發送到郵件。 我的問題是我有一個由javascript填充的span,但是沒有使用post函數發送該span的值。

QtyA = 0;
PrcA = 15;
document.getElementById("product1").innerHTML = PrcA;

<form method="POST" action="form-to-email.php" name="ofrm">

    <table border="0" cellpadding="0" width="550" id="table1">
        <tr>
            <td width="250">Product1</td>
            <td align="center" width="100">
            <input type="text" name="qtyA" size="5" tabindex="5" onchange="calculate()"/></td>
            <td align="right" width="60"><span id="product1" name="PrcA"/></span></td>
            <td align="right" width="140">
            <input type="text" name="totalA" size="12" tabindex="99" onchange="calculate()"/></td>
        </tr>
</table>

我試圖用

   <input type="text" name="PrcA" id="product1" size="5" tabindex="5" onchange="calculate()"/>

但輸入字段未由javascript填充

PHP

.....

    $qtyA = $_POST['qtyA'];
    $PrcA = $_POST['PrcA'];
    ...
    $email_body = "$qtyA $PrcA".

發送變量$ QtyA,但不發送$ PrcA

謝謝

也將值放在隱藏字段中。

嘗試這個:

QtyA = 0;
PrcA = 15;
document.getElementById("product1").innerHTML = PrcA;
document.getElementById("PrcA").value = PrcA;

<form method="POST" action="form-to-email.php" name="ofrm">
<input type="hidden" value="" name="PrcA" id="PrcA" />

<table border="0" cellpadding="0" width="550" id="table1">
    <tr>
        <td width="250">Product1</td>
        <td align="center" width="100">
        <input type="text" name="qtyA" size="5" tabindex="5" onchange="calculate()"/></td>
        <td align="right" width="60"><span id="product1" name="PrcA"  /></span></td>
        <td align="right" width="140">
        <input type="text" name="totalA" size="12" tabindex="99" onchange="calculate()"/></td>
    </tr>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM