大家好,我有一个问题,我有一个网页,里面有一个数据表,里面装满了来自我的数据库的数据。我有一列复选框和一个按钮。当我单击我的按钮时,我打开一个生成发票的新页面。我已经在jQuery中完成了一个脚本,该脚本使用复选框获取我的订单ID。
我的复选框的代码(我使用引导程序):
<td><div class="ckbox ckbox-success">
<input type="checkbox" class="select-invoice" data-idcommande="<?= $commande->getId()?>"/>
<label for="checkboxSuccess"></label>
</div>
</td>
这是我的按钮的代码(也是引导):
<a class="btn btn-labeled btn-warning" href="facture-facture_groupee.html" id="invoicebtn"> <span class="btn-label"><i class="fa fa-eur"></i></span>Facturer les commandes sélectionnées </a>
现在这是我点击按钮时制作的脚本:
$( "#invoicebtn" ).click(function() {
$('.select-invoice').each(function() {
$(this).data("idcommande");
});
});
这项工作很好(我已经用alert()
测试过)
但是现在我想把我收集的id放在另一个页面,但我不知道该怎么做。
感谢您的阅读,对不起我的英语,我是法国人。
使用 Ajax
在客户端和服务器之间进行通信。
客户:
$.post( "test.php", { name: "John", time: "2pm" } );
服务器:
if($_POST) {
$name = $_POST['name'];
$time = $_POST['time'];
}
我已经找到了我的问题的解决方案,感谢您的回答。
这是我的JS:
$("#boutonfacturer").click(function () {
var checked = $('input[name="id_commande[]"]:checked');
var tab = [];
checked.each(function () {
var value = $(this).val();
tab.push(value);
});
$.post("genererfacture-facture_groupee.html",
{
id: tab
}
).success(function(retour) {
console.log("Data Loaded: " + tab);
});
});