当并且仅当从new_order.php页面选择VAT模式的值是“含增值税”时,我才尝试将GST的值发送到order.js文件。
<div class="form-group row">
<label for="vat" class="col-sm-3 col-form-label" onChange="getVatMode(this.value);" align="right">VAT Mode</label>
<div class="col-sm-6">
<select name="vatMode" value="data" class="form-control" id="vatMode" required="required">
<option value="1">Without VAT</option>
<option value="2">With VAT</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="gst" class="col-sm-3 col-form-label" align="right">GST (13%)</label>
<div class="col-sm-6">
<input type="text" readonly name="gst" class="form-control form-control-sm" id="gst" required/>
</div>
</div>
并且我需要将此增值税值传递给order.js页面而不加载用于计算总和的
function calculate(dis,paid){
var sub_total = 0;
var gst = 0;
var net_total = 0;
var discount = dis;
var paid_amt = paid;
var due = 0;
$(".amt").each(function(){
sub_total = sub_total + ($(this).html() * 1);
})
gst = Math.round(0.13 * sub_total);
net_total = gst + sub_total;
net_total = net_total - discount;
due = net_total - paid_amt;
$("#gst").val(gst);
$("#sub_total").val(sub_total);
$("#discount").val(discount);
$("#net_total").val(net_total);
//$("#paid")
$("#due").val(due);
答案 0 :(得分:0)
使用Jquery,您可以使用$("#YourFormId").serialize()
:
$("form").on( "submit", function( event ) {
event.preventDefault();
console.log($(this).serialize());
});
要使表单元素的值包含在序列化的字符串中,该元素必须具有名称属性