Hi all this is my first post so hopefully someone here can help.
I am setting up a Java shopping cart called JShop. It is all installed and it works fine, however I am trying to make the form calculate a discount percentage based on how many products are ordered.
Now I am very, very new to Java but I have already made a start to the script.
Below is what I have so far...
This part selects the correct percentage:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin percentage
function findPercentage() {
var units = getNumberOfUnits();
var percentage = getPercentage(units);
return percentage;
}
function getNumberOfUnits() {
var units = allitems;
return units;
}
function getPercentage(units) {
if (units >= 100) return 45;
if (units >= 70) return 40;
if (units >= 40) return 35;
if (units >= 20) return 30;
if (units >= 10) return 25;
if (units <= 9) return 0;
}
// End percentage -->
<!-- Begin discount
function findDiscount() {
var numofblends = getNumberOfBlends();
var newpriceofblends = getNewPrice(numofblends);
var newprice = (numofblends*newpriceofblends)/100
return newprice;
}
function getNumberOfBlends() {
var numofblends = allitems;
return numofblends;
}
function getNewPrice(numofblends) {
if (numofblends >= 100) return 659;
if (numofblends >= 70) return 719;
if (numofblends >= 40) return 779;
if (numofblends >= 20) return 839;
if (numofblends >= 10) return 899;
if (numofblends <= 9) return 1199;
}
// End discount -->
Basically what I need to know is what it the correct way to make an equation that will find the percentage of a number?
Eg. 25% of ?28.86p or 45% of 47.45p etc....
Any help would be most appreciated.
Thanks.
I am setting up a Java shopping cart called JShop. It is all installed and it works fine, however I am trying to make the form calculate a discount percentage based on how many products are ordered.
Now I am very, very new to Java but I have already made a start to the script.
Below is what I have so far...
This part selects the correct percentage:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin percentage
function findPercentage() {
var units = getNumberOfUnits();
var percentage = getPercentage(units);
return percentage;
}
function getNumberOfUnits() {
var units = allitems;
return units;
}
function getPercentage(units) {
if (units >= 100) return 45;
if (units >= 70) return 40;
if (units >= 40) return 35;
if (units >= 20) return 30;
if (units >= 10) return 25;
if (units <= 9) return 0;
}
// End percentage -->
<!-- Begin discount
function findDiscount() {
var numofblends = getNumberOfBlends();
var newpriceofblends = getNewPrice(numofblends);
var newprice = (numofblends*newpriceofblends)/100
return newprice;
}
function getNumberOfBlends() {
var numofblends = allitems;
return numofblends;
}
function getNewPrice(numofblends) {
if (numofblends >= 100) return 659;
if (numofblends >= 70) return 719;
if (numofblends >= 40) return 779;
if (numofblends >= 20) return 839;
if (numofblends >= 10) return 899;
if (numofblends <= 9) return 1199;
}
// End discount -->
Basically what I need to know is what it the correct way to make an equation that will find the percentage of a number?
Eg. 25% of ?28.86p or 45% of 47.45p etc....
Any help would be most appreciated.
Thanks.