PDA

View Full Version : instant price quote calculator

basamdamdu
01-20-2011, 05:14 AM
Hi there,

I am trying to come up with an instant price quote calculator in javascript.

it would be a simple one with only three fields:
"label" -Number of Shirts
"label" -Number of Colors on Front
"label" -Number of Colors on Back

"button" calculate total

"results" total: \$xx per bag: \$xx

total price would decrease based on the number of shirts (more volume) / increase based on the number of colors both front and back.

something i found online that is 100% what i want: http://zeustees.com/about-us

i've found something here (http://javascript.internet.com/math-related/best-price.html) that will deal with the increase/decrease of volume and corresponding price but if anybody has a solution already, that would save me a lot of time and agony.

i am obviously not asking anyone to work for free but if someone could point me to a semblance of a solution, some code, something online that i could modify etc. i would love to learn javascript in the process and ideally come up with a working version of the calculator.

i tried to work with the .js from that website (http://zeustees.com/about-us) but it calls in some qq2.php page. so i haven't been able to replicate the solution. plus, i would assume that their price structure would be different than mine.

BD

vwphillips
01-20-2011, 03:15 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<title></title>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

function Cal(obj){
var args=Cal.arguments,frm=args[0].form,nu,tot=0;
var values=[];
for (var ip,z0=1;z0<args.length-1;z0++){
ip=frm[args[z0]];
ip.value=ip.value.replace(/\D/g,'');
values.push([ip.value,ip.parentNode.className]);
}
if (values[0][0].length>0){
nu=values[0][0];
tot=nu*values[0][1];
for (var z1=1;z1<values.length;z1++){
if (values[z1][0]){
tot+=values[z1][0]*values[z1][1]*nu
}
}
}
frm[args[args.length-1]].value='\$'+tot;
}
/*]]>*/

<body>
<form>
"label" -Number of Shirts<span class="10" ><input name="number" size="5"/></span><br />
"label" -Number of Colors on Front<span class="10" ><input name="front" size="5" /></span><br />
"label" -Number of Colors on Back<span class="12" ><input name="back" size="5" /><br />
<input type="button" name="" value="Calculate" onmouseup="Cal(this,'number','front','back','total');" />
<input name="total" />
</form>
</body>

</html>

basamdamdu
01-21-2011, 06:17 AM
wow!! thanks a million Vic!!

this is sure going to help me a bunch. i'm now gonna try to add the increase/decrease volume price thing and maybe a constant (like set up cost etc)...

this should be within my skill range, i think... i hope...

i'll post the whole thing once done.