Expand my Community achievements bar.

Variable prices based on quantity

Avatar

Former Community Member
G'day everyone.



I am hoping someone could please help me. I am new to LiveCycle and know just enough about scripts to get myself totally confused, so please explain things much like you would to a 7 year old...



Ok, here is what I am trying to acheive.



I have a dropdown list with 'products' populated from an array, user selects product a from the list and the 'Unit Price' text field is then populated using the data from the same array.



This was working fine, however I then added a 'Quantity' field and tried to modify the script so that if the qty = 1 then Product A unit price is $30 or if qty is between 3 and 7 then Product A unit price is $20, etc.



However, since expanding the script with the var Price array I can't get the 'Price' text field to populate.



I have included the script I am using below, can anyone see where I am going wrong or is there a simpler way to do it??



Thanks for your help



Current Script:

// Array of Products.



var Module = new Array(" ",

"1MD | 1 Deep (93mm x 62mm)",

"2MD | 2 Deep (188mm x 62mm)",

"2MW | 2 Wide (92mm x 127mm)");



// Array of Casual Unit prices.



var Price1to3 = new Array(null,

136.50,

273.00,

273.00);



// Array of 4-6 Unit prices.



var Price4to6 = new Array(null,

122.85,

245.70,

245.70);



// Array of 7-12 Unit prices.



var Price7to12 = new Array(null,

116.02,

232.04,

232.04);



// Array of 13-24 Unit prices.



var Price13to24 = new Array(null,

102.37,

204.74,

204.74);



// Populate the part number Drop-down List.



function populateAdvert(dropdownField)

{

var i;

for (i=0; i < Module.length; i++)

dropdownField.addItem(Module[i]);

}



// Populate the description and unit price fields.



function getDesc(advert, InsertPrice)

{

var i;

for (i = 0; i < advert.length; i++) // Go through the entire list of part numbers to find the one that is currently selected.



{



if (Module[i] == advert) // When we find the part number currently selected.



{



var qty = getField(numQTY).value;



if (qty <=3) InsertPrice.rawValue = Price1to3[i]; // and put the unit price in the unit price field.



else if (qty > 3 && qty <7) InsertPrice.rawValue = Price4to6[i];



else if (qty > 6 && qty <13) InsertPrice.rawValue = Price7to12[i];



else InsertPrice.rawValue = Price13to24[i];

break; // No need to go further if there is a match.



}



}



}
1 Reply