[英]Passing table data with post variables
Basically I have a table with a bunch of numbers coming from a database with columns for totals/subtotals. 基本上我有一个表,其中包含来自数据库的一堆数字,其中包含总计/小计的列。 I do not intend to add any of the totals to the database, but I need to pass the total numbers from one page to the next.
我不打算将任何总数添加到数据库中,但我需要将总数从一个页面传递到下一个页面。 I can't seem to properly pass them as post variables using PHP... I'm wondering if this is a bad tactic firstly, secondly what should I do instead?
我似乎无法正确地将它们作为post变量使用PHP传递...我想知道这是否是一个糟糕的策略,其次,我应该做什么呢?
And if this is possible, how would I go about doing it? 如果这是可能的,我将如何去做呢? I haven't been able to derive the text between the < td >'s from using $_POST['tdname'].
我无法使用$ _POST ['tdname']在<td>之间导出文本。
Example code: 示例代码:
<form method="POST" action="newcivilreport2.php">
<div style="width:800px;text-align:left;margin:0 auto;padding-bottom:5px;">A. PENDING BALANCE</div>
<table border="1" style="width:800px;" ID="tableA">
<th style="width:40%;"></th>
<th style="width:15%;">Civil</th>
<th style="width:15%;">Asbestos</th>
<th style="width:15%;">Domestic</th>
<th style="width:15%;">Total</th>
<tr>
<td>1. Pending Balance from Previous Month</td>
<td id="PendingCivil" name="PendingCivil">66</td>
<td id="PendingAsbestos">0</td>
<td id="PendingDomestic">0</td>
<td id="PendingTotal">0</td>
</tr>
</table>
<input type="submit" value="Save and Continue -->"></form></div>
newcivilreport2.php: newcivilreport2.php:
<?php
$_POST['PendingCivil'];
?>
POST will only send inputs like <input type='text|file|hidden|ect' />
. POST只会发送
<input type='text|file|hidden|ect' />
。 Perhaps you would like to use AJAX. 也许您想使用AJAX。 For example:
例如:
<table id="tData">
<tbody>
<tr>
<td class='dataVal1'>100</td>
...
$(document).ready(function() {
var toServer = {};
var data = $('#tData tbody tr td').each(function(key, value) {
toServer[$(this).attr('id')] = $(this).text();
});
$.ajax({
url: 'page.php',
data: toServer,
type: 'POST'
})
});
The <td>
tag of a table does not provide values for a form. 表的
<td>
标记不提供表单的值。
Use a hidden field for your post: 为帖子使用隐藏字段:
http://www.w3schools.com/tags/att_input_type.asp http://www.w3schools.com/tags/att_input_type.asp
...
<td>1. Pending Balance from Previous Month</td>
<td id="PendingCivil">66<input type="hidden" name="PendingCivil" value="66"></td>
...
Also, is it inside of a form? 还有,它是在一个表格内吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.