I am trying to send data from form to the mail using php script. My problem is that i have span which is populated by javascript, but value of this span is not being sent using post function.
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>
i tried to replace span with
<input type="text" name="PrcA" id="product1" size="5" tabindex="5" onchange="calculate()"/>
but input field is not populated by the javascript
php
.....
$qtyA = $_POST['qtyA'];
$PrcA = $_POST['PrcA'];
...
$email_body = "$qtyA $PrcA".
variable $QtyA is sent, but $PrcA is not
thanks
I am trying to send data from form to the mail using php script. My problem is that i have span which is populated by javascript, but value of this span is not being sent using post function.
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>
i tried to replace span with
<input type="text" name="PrcA" id="product1" size="5" tabindex="5" onchange="calculate()"/>
but input field is not populated by the javascript
php
.....
$qtyA = $_POST['qtyA'];
$PrcA = $_POST['PrcA'];
...
$email_body = "$qtyA $PrcA".
variable $QtyA is sent, but $PrcA is not
thanks
Share Improve this question asked Sep 25, 2015 at 9:18 ivanzivanz 8253 gold badges12 silver badges32 bronze badges 3-
You really shouldn't be using the
<table>
tag inside the form element... – Jordan Davis Commented Sep 25, 2015 at 9:29 - thanks for the note, i assume i will try to change this to clean css in the future – ivanz Commented Sep 25, 2015 at 9:44
-
also, you can always call
var_dump($_POST)
if your doing testing. – Jordan Davis Commented Sep 25, 2015 at 9:55
1 Answer
Reset to default 3Put the value in an hidden field also.
Try this:
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>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745510654a4630756.html
评论列表(0条)