Warning: Creating default object from empty value in /home/thescrip/public_html/jclass/load_globes.php on line 22

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/thescrip/public_html/jclass/load_globes.php:22) in /home/thescrip/public_html/jincludes/globals.php on line 43

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/thescrip/public_html/jclass/load_globes.php:22) in /home/thescrip/public_html/jincludes/globals.php on line 43

Warning: Creating default object from empty value in /home/thescrip/public_html/jclass/load_globes.php on line 22

Warning: Creating default object from empty value in /home/thescrip/public_html/jclass/db_func.php on line 61

Warning: Creating default object from empty value in /home/thescrip/public_html/jclass/db_func.php on line 61

Warning: Creating default object from empty value in /home/thescrip/public_html/jclass/db_func.php on line 61
JavaScript Commission Calculator
TheScriptCenter.com


print page

Commission Calculator

Description: Script automatically configures commissions monthly, yearly etc. Use as tool for Affiliate programs, and Network Marketing Programs.

Features: Enter in Level%'s, Product Names, Product Costs.

Example:

Code

 

<form name="mef">
<script language=javascript>
/* JavaScript Commission Calculator written by Jason J. Russo
http://thescriptcenter.com
jasonrusso@thescriptcenter.com
*/
 
// Enter in the level percentage payouts here. //
// Do not use % sign. //
var level = new Array();
level[1]="40";
level[2]="5";
level[3]="5";
level[4]="2";
level[5]="2";
level[6]="1";
level[7]="1";
// Enter in the product name, then cost.
// Example: 
// product[0][0] = "widget"; 
// product[0][1]="24.95";
 
var product = new Array();
var price = new Array();
/*  Product, then cost . Do not use $ sign.*/
 
product[1] = "Basic";
price[1] = "19.95";
product[2] = "Pro"; 
price[2] = "39.95";
product[3] = "Corporate"; 
price[3] = "79.95";
product[4] = "";
price[4] = "";
product[5] = "";
price[5] = "";
 
/* Styles */
var bgcolor='#FFFFFF';
var fontstyle='verdana';
var fontcolor='#000000';
var fontsize='10pt';
var bordercolor = '#000000';
var borderwidth='0';
 
/*########### Done Editing. #################*/
 
var x=1;
 
function roundoff(commissions) {
 
commissions=Math.round(commissions*100)/100;
/* Turn me back into a string. */
commissions= commissions + "";
if (commissions.charAt(commissions.length-2)=="."){
commissions+="0";
}
if(commissions.indexOf(".")==-1){ commissions+=".00";
}
 
document.mef.hidcomm.value = commissions;
 
}
function figure_commissions(x) {
 
if(document.mef.referrals.value == "") {
alert("Please enter a numeric value for referrals.");
document.mef.referrals.focus();
return;
 }
if(isNaN(document.mef.referrals.value)) {
alert(document.mef.referrals.value + " is not a valid number. Please enter a numeric value for referrals.");
document.mef.referrals.focus();
return;
 }
var numofref = document.mef.referrals.value;
var whaprice = document.mef.hidprice.value;
var monthlyincome=0;var yearlyincome=0;
var commissions=0;
commissions1 = numofref * whaprice;
x=1;
 
if(level[1]) {
commissions = commissions1 * level[1]/100;
roundoff(commissions);
document.mef.level1.value =  document.mef.hidcomm.value;
monthlyincome = commissions;
 
 }
if(level[2]) {
commissions = commissions1 * level[2]/100;
roundoff(commissions);
document.mef.level2.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[3]) {
commissions = commissions1 * level[3]/100;
roundoff(commissions);
document.mef.level3.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[4]) {
commissions = numofref * whaprice;
commissions = commissions * level[4]/100;
roundoff(commissions);
document.mef.level4.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[5]) {
commissions = numofref * whaprice;
commissions = commissions * level[5]/100;
roundoff(commissions);
document.mef.level5.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[6]) {
commissions = numofref * whaprice;
commissions = commissions * level[6]/100;
roundoff(commissions);
document.mef.level6.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[7]) {
commissions = commissions * level[7]/100;
roundoff(commissions);
document.mef.level7.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[8]) {
commissions = commissions * level[8]/100;
roundoff(commissions);
document.mef.level8.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 }
if(level[9]) {
commissions = commissions * level[9]/100;
roundoff(commissions);
document.mef.level9.value = document.mef.hidcomm.value;
monthlyincome = monthlyincome + commissions;
 
 }
roundoff(monthlyincome);
 
document.mef.monthlyinc.value =document.mef.hidcomm.value;
var yearlyinc = monthlyincome * 12;
roundoff(yearlyinc);
document.mef.yearlyinc.value = document.mef.hidcomm.value;
 }
 
var debug = '0';
 
if(debug == 1) {
document.write('<textarea rows=20 cols=70>');
 }
 
document.write('<style>input.bl { border-style:solid;border-width:1px;border-color:' + bgcolor + '; } TD { font-family:' + fontstyle + ';font-size:' + fontsize + ';}</style><table border=' + borderwidth + '  bordercolor=' + bordercolor + ' bgcolor=' + bgcolor + '><tr>');
document.write('<td colspan=' + level.length + ' align=center>Enter in Number of Referrals: <input type=text size=3 name=referrals><BR>Choose Product: <select name=product onchange="document.mef.hidprice.value = document.mef.product.options[document.mef.product.selectedIndex].value,figure_commissions()"><option value=0>Select One');
 
while(x < product.length) {
if(product[x] != '') {
document.write('<option value="' + price[x] + '">' + product[x] + ' $' + price[x]);
 
 }
x++;
 }
document.write('</select></TD></TR>');
 
x=1;
 
while(x < level.length) {
if(level[x] != "") {
document.write('<TD align=center><font style="font-family:' + fontstyle + ';color:' + fontcolor + ';font-size:' + fontsize + ';">Level' + x + '<BR>' + level[x] + '%</font></TD>');
 }
x++;
 }
document.write("<TR>");
/* Now place text fields. */
x=1;
while(x < level.length) {
if(level[x] != "") {
document.write('<TD>$<input class=bl type=text size=6 style="background-color:' + bgcolor+ '" name=level' +  x + '></TD>');
 }
x++;
}
document.write('<TR><TD colspan=' + x + '>Estimated Monthly Income: $<input type=text name=monthlyinc class=bl size=20 style=' + '"background-color:' + bgcolor + ';"><BR>Yearly Income: $<input type=text class=bl name=yearlyinc size=12 style=' + '"background-color:' + bgcolor + ';"><BR><center><input type=button value=Calculate onclick="figure_commissions()" class=bl><input type=hidden name=hidprice value=0><input type=hidden name=hidcomm value=0></center>');
document.write("</TR></table>");
 
</script>
 
 
</form>