I'm trying to add a commission calculator to my new website, and it works
properly for the first two of three form entries, but I wish to add a 3rd
level calculation.
I'm not familiar with javascript at all really, so I have no clue what to add
to the script to get it to process the third field into the calculation.
You can see the form on this page:
http://dmp.safelistsynergy.com
And the script code is this:
function calculate(intDirect, intIndirect){
var intResult = 0;
tp=0;
if (((isNaN(intDirect)) || (isNaN(intIndirect))) || ((intDirect == "") || (intIndirect == ""))){
document.frmCalculator.txtPartner.value = "$";
}
else
{
intResult = (intDirect * 5);
tp = intIndirect * intDirect;
intResult += (tp * 2) - 10;
document.frmCalculator.txtPartner.value = formatCurrency("" + Math.round(intResult));
}
}
function formatCurrency(strValue)
{
var intCount = 0;
var i = 0;
var strChar = "";
var strTemp1 = "";
var strTemp2 = "";
for (i = strValue.length - 1; i >= 0; i--)
{
strChar = strValue.charAt(i);
if (intCount == 3)
{
strTemp1 += ",";
strTemp1 += strChar;
intCount = 1;
continue;
}
else
{
strTemp1 += strChar;
intCount ++;
}
}
for (i = strTemp1.length - 1; i >= 0; i--)
{
strChar = strTemp1.charAt(i);
strTemp2 += strChar;
}
strTemp2 = "$" + strTemp2;
return strTemp2;
}
What I wish to do is name the 3rd level entry intIndirectb and have it
calculated into the total. The level payments are:
1st: 5
2nd: 2
3rd: 2
The first two calculate properly, but I need to include the third level
and process the outcome minus 10 as it is currently doing for the first two
levels.
Probably really simple, but I just don't know java.
If you can get this running it would be greatly appreciated.
Neil Holmberg