[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.7

Calculating form - and adding a percentage -  by clicking checkbox

Asked by seanpowell in JavaScript

I've been working on this for awhile but appear to be going in the wrong direction.
This form is used to calculate member dues, and all works just fine. The addition is a checkbox that - when checked, adds 1/12th of the value of the subtotal, and recalculates the new gst and grand total. I have a feeling this is a lot simpler than I've made it out to be - can anyone help?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
function calcMem(form)
{
        var totalSales = stripCharsInBag(form.totalSales.value,",");
        var foreignSales = stripCharsInBag(form.foreignSales.value,",");
        var grossSales = totalSales - foreignSales;
        var gst = .05;
        form.grossSales.value = "$"+ currency(grossSales);
        var category = calcCat(grossSales);
        form.memCat.value = category;
        var fsubTotal = getSubTotal(category,grossSales).toFixed(2)*1;
        form.subTotal.value = "$" + currency(fsubTotal);
        gstTotal = (fsubTotal * gst).toFixed(2)*1;
        form.gst.value = "$" + currency(gstTotal);
        finalTotal = fsubTotal + gstTotal;
        form.total.value = "$" + currency(finalTotal)
        return;
}
 
function calcCat(calcSales)
{
	var memCategory;
	if (calcSales < 2500000)
	{
	memCategory = "C";
	}
	if (calcSales >= 2500000 && calcSales < 6000000)
	{
	memCategory = "C";
	}
	if (calcSales >= 6000000 && calcSales < 10000000)
	{
	memCategory = "D";
	}
	if (calcSales >= 10000000 && calcSales < 20000000)
	{
	memCategory = "E";
	}
	if (calcSales >= 20000000 && calcSales < 35000000)
	{
	memCategory = "F";
	}
	if (calcSales >= 35000000 && calcSales < 50000000)
	{
	memCategory = "G";
	}
	if (calcSales >= 50000000 && calcSales < 75000000)
	{
	memCategory = "H";
	}
	if (calcSales >= 75000000 && calcSales <100000000)
	{
	memCategory = "I";
	}
	if (calcSales >= 100000000 && calcSales <150000000)
	{
	memCategory = "J";
	}
	if (calcSales >= 150000000 && calcSales <200000000)
	{
	memCategory = "K";
	}
	if (calcSales >= 200000000)
	{
	memCategory = "L";
	}
	return memCategory;
}
 
function stripCharsInBag (s, bag)
{
 
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++)
	{
	    var c = s.charAt(i);
	    if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
 
function getSubTotal(category,grossSales)
{
	switch(category)
	{
		case "C":
		var baseFee = 3150
		var increment = .6021
		if (grossSales <= 2500000)
		{
			subTotal = baseFee;
		}else{
			grossSales = grossSales - 2500000;
		increment = increment * (grossSales/1000);
		subTotal = increment  + baseFee;
		}
		break
		case "D":
			var baseFee = 5257
			var increment = .5808
			grossSales = grossSales - 6000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "E":
			var baseFee = 7581
			var increment = .3925
			grossSales = grossSales - 10000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "F":
			var baseFee = 11506
			var increment = .2337
			grossSales = grossSales - 20000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "G":
			var baseFee = 15012
			var increment = .1616
			grossSales = grossSales - 35000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "H":
			var baseFee = 17436
			var increment = .1162
			grossSales = grossSales - 50000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "I":
			var baseFee = 20340
			var increment = .1016
			grossSales = grossSales - 75000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "J":
			var baseFee = 22879
			var increment = .0868
			grossSales = grossSales - 100000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "K":
			var baseFee = 27221
			var increment = .0694
			grossSales = grossSales - 150000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
		case "L":
			var baseFee = 30692
			var increment = .0640
			grossSales = grossSales - 200000000;
			increment = increment * (grossSales/1000);
			subTotal = increment + baseFee;
		break
	}
	return subTotal;
}
 
function roundClean(number,precision)
{
	if (typeof precision=="undefined") precision=0;
	for (var i=10;i>=precision;i--) number=Math.round(number*Math.pow(10,i))/Math.pow(10,i);
	return number;
}
 
function currency(anynum)
{
	anynum=eval(anynum)
	workNum=Math.abs(roundClean(anynum,2));workStr=""+workNum
	if (workStr.indexOf(".")==-1)
	{
		workStr+=".00"
	}
	dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
	pStr=workStr.substr(workStr.indexOf("."))
	while (pStr.length<3)
	{
		pStr+="0"
	}
	if (dNum>=1000)
	{
		dLen=dStr.length
		dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
	}
 
	if (dNum>=1000000)
	{
		dLen=dStr.length
		dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
	}
	retval = dStr + pStr
	if (anynum<0)
	{
		retval="("+retval+")"
	}
	return retval;
	return "$"+retval
}
 
<form>
<table border="1" cellpadding="6" cellspacing="1" bordercolor="#488CAD">
	<tr>
		<td>Total Sales from last financial statement:</td>
		<td><input type="text" name="grossSales"> <input type="button" value="Calculate" name="Calculate" onFocus="calcMem(this.form)"></td>
	</tr>
	<tr>
		<td>Category</td>
		<td><input type="text" name="memCat" size="2"></td>
	</tr>
	<tr>
		<td>Your fee</td>
		<td><input type="text" name="subTotal"></td>
	</tr>
	<tr>
		<td>Check this box if using Option 2 (1/12 of Fee) <input type="checkbox" name="OptionBox" value="Yes"></td>
		<td><input type="text" name="Option2"></td>
	</tr>
	<tr>
		<td>5% G.S.T.</td>
		<td><input type="text" name="gst"></td>
	</tr>
	<tr>
		<td>Total</td>
		<td><input type="text" name="total"></td>
	</tr>
</table>
</form>
[+][-]03/11/09 02:39 PM, ID: 23862685Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/11/09 02:50 PM, ID: 23862753Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/12/09 05:41 AM, ID: 23867510Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/12/09 05:44 AM, ID: 23867535Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/12/09 07:29 AM, ID: 23868715Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/12/09 07:40 AM, ID: 23868847Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/12/09 10:48 AM, ID: 23871355Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/12/09 02:33 PM, ID: 23873853Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/12/09 02:35 PM, ID: 23873870Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/12/09 02:46 PM, ID: 23874016Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: JavaScript
Sign Up Now!
Solution Provided By: robinu
Participating Experts: 1
Solution Grade: A
 
[+][-]03/12/09 03:13 PM, ID: 23874297Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625