I’m trying to make a simple script for a retailer with a webpage – we have three Fruits – Apple , Banana, Orange
Two Qualities each – Apple ( bad and good) , Banana( bad & good) and Orange (bad and good)... Bad in all cases an inferior quality.
So I have two quality options -- good and bad
Quantity from 1 to 10
I did something like this with array but it is only applicable to two variable not three . Final result I want is –
I chose Apple > good > 5 units = 5*4 = 20
Form Option - select (apple, banana, orange), select(good, bad) , select(number of units)
Here is what I have done
costperfruit = new Array(4,5,6, 7,8,9);
function setcost()
{
cpp = costperfruit[document.frm.colour_fruit.value*1-1];
sum = cpp*document.frm.numberUnits.value;
sum += "";
pos = sum.indexOf(".");
if (pos>0)
{
sum = sum.substring(0,pos+3);
if (sum.indexOf(".")+3>sum.length)
sum += "0";
}
else
sum += ".00";
document.frm.cost_per_fruit.value = cpp;
document.frm.total_sum.value = sum;
}
With this I can easily multiply number of units with cost of fruits. Green option is inferior quality in each case thus sells for 3,5,7 , One USD less than red, yellow, red orange
I want to see price when I choose --
orange> bad> 3 = 7*3 = 21 apple> bad > 4 units > 3*4 = 12
I'm using select form in HTML.