'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&id=' + $(this).val());
$.ajax({
url : dataUrl,
+ async : false,
success : function(html){
htmlText = html.split( '|' , 2);
$('#soft_credit_contact_' + rowCnt).val(htmlText[0]);
return false;
});
+ $('input[name^="soft_credit_contact["]').change(function(){
+ var rowNum = $(this).attr('id').replace('soft_credit_contact_','');
+ var totalAmount = Number($('#total_amount').val());
+ //assign total amount as default soft credit amount
+ $('#soft_credit_amount_'+ rowNum).val(totalAmount);
+ if (rowNum > 1) {
+ var scAmount = Number($('#soft_credit_amount_'+ (rowNum - 1)).val());
+ if (scAmount < totalAmount) {
+ //if user enters less than the total amount and adds another soft credit row,
+ //the soft credit amount default will be left empty
+ $('#soft_credit_amount_'+ rowNum).val('');
+ }
+ }
+ });
+
});