Javascript issue

Moderator: crythias

Post Reply
OTRS newbie
Posts: 14
Joined: 18 Dec 2018, 16:38
OTRS Version?: OTRS6.0
Real Name: Sam

Javascript issue

Post by sansflance »

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;

OTRS wizard
Posts: 565
Joined: 15 Dec 2016, 15:13
OTRS Version?: 3.x–6.0.x
Real Name: Emin
Company: Efflux GmbH

Re: Javascript issue

Post by zzz »


Well, for multiple reasons on the JS code.
Are you trying to go for PrQuotationAmount = (PrQuantity1 * PrPrice1) + (PrQuantity2 * PrPrice2) etc.?

Best regards
Professional OTRS services for development, consulting, hosting and support: – German | – English

Free and premium OTRS add-ons (TextModule, AdBlocker, ModernSkin, ModernSkinCustomer etc.):

Post Reply