![](/img/trans.png)
[英]I have an sql table with “postId” as a field, I'm trying to “get” that into a url when the user clicks a link
[英]How to make a new field in table when user clicks on a link
我的表格如下图所示:
// supplier info
$supplier_name = $_POST['supplier_name'];
$supplier_sending = $_POST['supplier_sending'];
$supplier_guarantee = $_POST['supplier_guarantee'];
$supplier_price = $_POST['supplier_price'];
$supplier_colors = $_POST['supplier_colors'];
$supplier_info = array($supplier_name,
$supplier_sending,$supplier_guarantee, $supplier_price, $supplier_colors);
$proSupply = json_encode($supplier_info);
这样,我可以将$proSupply
var成功提交到表中。 但是,正如您在打印屏幕中看到的那样,我添加了一个名为“ 添加更多供应商:+”的链接,它的作用基本上是在表单中添加一个新的表格行。 因此,用户可以插入多个供应商信息。
但是问题是我的表上只有一个字段应包含“供应商信息”。 而且由于我不知道用户要添加多少个供应商,因此无法指定MySQL表中归档的供应商数量。
所以我的问题是:每当用户单击PHP中的+链接(例如,vendor_info_1,Supplier_info_2等)时,是否可以在表中创建新的自定义字段?
更新1 :
这是为我的表格表单提供新行的脚本。
<script>
$("#addbtn").click(function(){
var next = parseInt($('#counter').val()) + 1;
$("#group").append("<table class='table table-hover'>
<tr>
<th style='padding-left:10px'>Name of supplier ("+next+")</th>
<th>Terms of sending</th>
<th>Guarantee</th>
<th>Price</th>
<th>Colors (use , for separation)</th>
</tr>
<tr>
<td style='padding-left:10px'><input name='supplier_name_("+next+")' type='text'></input></td>
<td><input name='supplier_sending_("+next+")' type='text'></input></td>
<td><input name='supplier_guarantee_("+next+")' type='text'></input></td>
<td><input name='supplier_price_("+next+")' type='text'></input></td>
<td><input name='supplier_colors_("+next+")' type='text'></input></td>
</tr>
</table>");
$('#counter').val(next);
});
</script>
是的,我的库存和会计软件中也有类似的概念。 您可以使用javascript或更佳的jquery来处理。 您可以为供应商创建隐藏行。 当基于您的应用程序触发事件时,将创建一个副本以获取另一个供应商行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.