Hi, Can someone please advise me where am i going wrong in below.
DynamicField_PrQuantity1-10 are input type text.
DynamicField_PrPrice1-10 are select dropdown
DynamicField_PrQuotationAmount is a text field.
For any change in Quantity field, i have to multiply it with price for all 10 fields and keep the total in PrQuotationAmount value.
var Quantities = ['DynamicField_PrQuantity','DynamicField_PrQuantity2','DynamicField_PrQuantity3','DynamicField_PrQuantity4','DynamicField_PrQuantity5','DynamicField_PrQuantity6','DynamicField_PrQuantity7','DynamicField_PrQuantity8','DynamicField_PrQuantity9','DynamicField_PrQuantity10'],
Prices = ['DynamicField_PrPrice','DynamicField_PrPrice2','DynamicField_PrPrice3','DynamicField_PrPrice4','DynamicField_PrPrice5','DynamicField_PrPrice6','DynamicField_PrPrice7','DynamicField_PrPrice8','DynamicField_PrPrice9','DynamicField_PrPrice10'];
$.each(Quantities).on('blur', function () {
var QuotationAmount=0;
for ( i=0; i<10; i++){
var Price=$("#" + Prices).val();
var Quantity = $("#" + Quantities).val();
if ( Quantity != '' ){
var RawPrice = Price.substring(Price.indexOf("_")+1) || 0;
QuotationAmount=QuotationAmount + (RawPrice * Quantity );
}
}
$('#DynamicField_PrQuotationAmount').innerHTML = QuotationAmount;
});
};
Javascript issue
Moderator: crythias
-
- Znuny newbie
- Posts: 14
- Joined: 18 Dec 2018, 16:38
- Znuny Version: OTRS6.0
- Real Name: Sam
-
- Znuny superhero
- Posts: 889
- Joined: 15 Dec 2016, 15:13
- Znuny Version: All
- Real Name: Emin
- Company: Efflux GmbH
- Contact:
Re: Javascript issue
Hi,
Well, for multiple reasons on the JS code.
Are you trying to go for PrQuotationAmount = (PrQuantity1 * PrPrice1) + (PrQuantity2 * PrPrice2) etc.?
Best regards
Emin
Well, for multiple reasons on the JS code.
Are you trying to go for PrQuotationAmount = (PrQuantity1 * PrPrice1) + (PrQuantity2 * PrPrice2) etc.?
Best regards
Emin
Professional OTRS, Znuny & OTOBO services: efflux.de | efflux.de/en/
Free and premium add-ons: German | English
Free and premium add-ons: German | English