当我在金额投标输入文件中输入一个值时,我选择了一个付款类型,例如Cash作为付款。它完美地运作。 如果我选择信用卡作为付款,那同样的事情。
问题 现在,如果我在金额投标输入中输入新值并选择现金支付或信用作为现金已经退出的付款...它会添加新的付款作为现金或信用......
所有我需要的,如果选择现金支付,那么我可以添加它不超过一次相同的信用卡支付..如何解决这个... 选择付款现金或信用卡被选中一次。每笔付款
任何帮助都会感激不尽。
下面包含的代码片段以及jsfiddle http://jsfiddle.net/cy2zwxpL/
<span id="amount_tendered_label">Grand total</span>
<input id="Grandtotal" value="1500.00" class="form-control" disabled=""><br/><br/>
<span id="amount_tendered_label">Amount Tendered:</span>
<input id="amount_tendered" placeholder="0.00" value="" name="amount_tendered" class="form-control"> <br/><br/>
<span>Payment Type:</span>
<select id="paymenttype" name="paymenttype" class="form-control">
<option></option>
<option value="Cash">Cash</option>
<option value="Credit">Credit Card</option>
</select>
<div id="theading" style="display:none;">
<span style="width: 1%;">#</span>
<span style="width: 1%;">Type</span>
<span style="width: 3%;">Amount</span>
</div>
<form id="toinvoice" action="" method="post" style="display:hidden" target="_blank">
<input type="hidden" name="cash" value="">
<input type="hidden" name="credit" value="">
<div id="payment_contents" style="display:none;">
</div>
</form>
$(document).ready(function($) {
$('#paymenttype').blur(function(event) {
var Grandtotal = $('#Grandtotal').attr('value');
var paymentContents = $('#payment_contents');
var theading = $('#theading');
var amountPaid = $('#amount_tendered').val();
var removePaid = $("input[name='amount_tendered']");
var dataCash = $("input[name='cash']");
var dataCredit = $("input[name='credit']");
var option = $(this).children("option").filter(":selected").text();
if(!option.trim()){
} else {
if(option === 'Cash' && dataCash.val() == '') {
if(amountPaid == '' && dataCash !== '') return ;
var output = '';
output +='<tr>';
output +='<td> x </td>';
output +='<td>Cash</td>';
output +='<td><i class="fa fa-rouble sm"></i>'+amountPaid+'.00'+'</td>';
output +='</tr>';
// appending output
paymentContents.append(output);
dataCash.val(amountPaid);
removePaid.attr('value', '0.00');
// showing thead
theading.show();
// showing tbody
paymentContents.show();
return;
}
else {
if(amountPaid == '' && dataCredit !== '') return ;
var output = '';
output += '<tr>';
output += '<td> x </td>';
output += '<td>Credit</td>';
output += '<td> <i class="fa fa-rouble sm"></i>'+amountPaid+'.00'+'</td>';
output += '</tr>';
paymentContents.append(output);
dataCredit.val(amountPaid);
removePaid.attr('value', '0.00');
paymentContents.show();
theading.show();
}
}
});
});