我有两个地址表格。一种是计费,另一种是运输。当用户选中“到相同地址的发货”复选框时,发货表格将被隐藏。
当我在单击复选框之前通过表单时,未提交表单。选中该复选框时,将发送两种形式的准确数据,但是当用户取消选中该复选框时,帐单邮寄地址将发布三次。
我使用jQuery和Ajax代码提交表单。
$(document).ready(function(){
$('.le-checkbox').click(function(){
if(this.checked) {
$("#deliveryadd").hide();
$(".le-checkbox").attr("checked", "checked");
$('#submit').click(function(){
var address= $('#address').val();
var city_id= $('#city_id').val();
var user = {{Auth::user()->id}};
console.log(address,city_id,user);
console.log(address,city_id,user);
billing(address,city_id,user);
shipping(daddress,dcity_id,user);
});
}
else {
$("#deliveryadd").show();
$(".le-checkbox").removeAttr("checked");
$('#submit').click(function(){
var address= $('#address').val();
var city_id= $('#city_id').val();
var user = {{Auth::user()->id}};
console.log(address,city_id,user);
billing(address,city_id,user);
});
$('#deliverySubmit').click(function(){
var daddress= $('#de_address').val();
var dcity_id= $('#de_city_id').val();
var user = {{Auth::user()->id}};
console.log(daddress,dcity_id,user);
shipping(daddress,dcity_id,user);
});
}
});
function billing(baddress,bcity,buser){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
阿波罗的战车
相关分类