如何传递每个Php值到javascript URL(只显示1相同的行记录)
How to Pass every Php value to javascript URL (only showing 1 same row record)
以下编码需要帮助。然而,我得到了一些运行没有,当我按下编辑按钮时,它只显示运行没有'1',其他运行不像2或3也显示运行不1,当我按下编辑第2行和第3行。我在index.php
文件中遇到了问题:
<html>
<?php
$rb = $connect->Execute("SELECT * FROM IT_Dept.dbo.testingHeader A LEFT JOIN IT_Dept.dbo.testingDetail B
ON A.invoiceno=B.invoiceno_dt
WHERE A.invoiceno = '".$search."'");
}
$invoiceno = $rb->Fields("invoiceno");
$company = $rb->Fields("company");
$custname = $rb->Fields("custname");
$newadd=str_replace("<br />","'n",$custadd);
//table details
?>
<body>
<?php
echo "<form id= 'form2' method='post'><table id='tabledesc' border=1>
<tr>
<th>Description </th>
<th>Qty</th>
<th >Unit Price(Before GST)</th>
<th>Total(Before GST)</th>
<th >*Total GST</th>
<th >Amount(RM)</th>
<th >Tax input/output</th>
<th >Debit Acc</th>
</tr>";
while(!$rb->EOF) {
$description = $rb->Fields("description");
$invoiceno_dt = $rb->Fields("invoiceno_dt");
$runningno = $rb->Fields("runningno");
$qty = $rb->Fields("qty");
$unitprice = $rb->Fields("unitprice");
$totalb4gst = $rb->Fields("totalb4gst");
$gst = $rb->Fields("gst");
$amount = $rb->Fields("amount");
>Fields("creditacc");
$description = $description->value;
$invoiceno_dt = $invoiceno_dt->value;
$runningno = $runningno->value;
$qty = $qty->value;
$unitprice = $unitprice->value;
$totalb4gst = $totalb4gst->value;
$gst = $gst->value;
$amount = $amount->value;
echo "<tr><td>".$description."</td>";
echo "<td>".$qty."</td>";
echo "<td>".$unitprice."</td>";
echo "<td>".$totalb4gst."</td>";
echo "<td>".$gst."</td>";
echo "<td>".$amount."</td>";
echo "<input type='hidden' name = 'runningno' id='runningno' value = ' $runningno ' >";
echo "<td><button onclick='openedit()'>Edit</button></td>";
invoiceno_dt=".$invoiceno_dt."&runningno=".$runningno."'>Edit</a></td>";
invoiceno_dt=".$invoiceno_dt."&runningno=".$runningno."'>x</a></td><tr>";
echo "<td><button onclick='opendelete()'>Delete</button></td>";
$rb->MoveNext();
}
?>
</table></form></body>
<script type="text/javascript">
var popup;
function openedit() {
var myinvoice = document.getElementById("invoiceno").value;
var no = <?php echo $runningno; ?>;
alert(no);
popup = window.open("edit.php?invoiceno="+myinvoice+'&runningno='+no, "Popup", "width=500,height=600");
popup.focus();
}
popup.focus();
}
</script>
<?php
$rb->close;
$connect->close;
?>
您可以将运行编号添加到页面中,例如:
<script type="text/javascript">
var no = <?php echo $runningNo; ?>;
</script>
试试这个
echo "<td><button onclick='"openedit('{$runningno}')'">Edit</button></td>";
除此之外,您最好删除输入字段中value属性中的空格。
echo "<input type='hidden' name='runningno' id='runningno' value ='$runningno' />";
按照建议使用模板文件
<html>
<!-- HTML code is here -->
<input type='hidden' name = 'runningno' id='runningno' value = '<?php print $runningno; ?>'></input>
<!-- Some other html -->
<?php
//your php code here
?>
<!-- HTML again -->
</html>
html
内的js也是一样<script type="text/javascript">
var testJsValue = "<?php print $ValueFromPHP; ?>";
</script>
试试这个
echo '<td><button onclick="openedit('''.$runningno.''')">Edit</button></td>';
相关文章:
- 如何应用带过滤器的ng if来过滤记录,并在同一页面中显示两个不同的视图
- AngularJS动态显示多条记录
- 使用模式消息/窗口显示数据库记录
- 使用自动完成文本框从mysql数据库获取表记录并显示在文本字段中
- 在显示使用 AngularJS 获取的记录时,如何在视图中循环
- 我想推送$scope.planlist=[]中的空白记录,但显示出相同的行为
- DataTable没有显示分页按钮和记录信息-JQuery
- 显示从 jsp 到 jsp 的记录 ${}
- 如何在网页上存储记录 (json) 并仅在“视图”上的记录上显示
- 剑道网格在删除后仍显示最后一条记录
- 网格视图在我输入特定记录名称时不显示记录
- NodeJS时间戳:比较时间并显示记录排序升序
- 通过单击“MVC 获取错误”中的“下一步”按钮 asp.net 在同一详细信息页面上显示记录
- 创建一个弹出窗口,该窗口根据父窗口提供的值显示记录
- 在动态文本字段中显示记录的计数器
- datatable.js-只显示表中的5个记录器+禁用“;显示记录”;
- 无法使用web服务显示记录
- 显示记录页面明智地使用ASP.NET和c#
- Extjs -在缓冲存储中迭代显示记录的最佳方式
- 如何使用 JSON 在表中显示记录