Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make an cost estimator

Status
Not open for further replies.
Thanks for the reply. I'm pretty new in learning javascript, is there any way you or someone else out there smarter at this than me can give me a coding example of this? That would be a real help! Thanks!
 
Personally, I think you're better off doing this server-side, as then users without JavaScript can use your site (accessibility, etc).

You can always use client-side JS to provide a "real-time" estimate, but have server-side regardless.

What server-side technology do you use (PHP, ASP, etc)? You'd be better off asking in the relevant forum for that, IMHO.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I generally use php. The link that I posted had the extension .jsp
 
I've got a working quote page but I'm having touble getting the total to round to the "dollar" decimal. For example I want $4.84 and I get $4.84444454433322. The link is: Here's my script:

Code:
<SCRIPT LANGUAGE="JavaScript">
/* Copyright Reaz Hoque, 1996, All right reserved. Web: [URL unfurl="true"]http://rhoque.com,[/URL] email: rhoque@rhoque.com
This code can be used for non-profit use only if the copyright notice is kept. */
// Courtesy of SimplytheBest.net - [URL unfurl="true"]http://simplythebest.net/scripts/[/URL]
var called=false;
var T_Price=0; 
var Line1_flag;
var Line1_print="";
var Line2_flag;
var Line2_print;
var Line3_flag;
var Line3_print;
var percent=".9"
var	P_Price=0;
var A_Price=0;
function compute(form){
called=true;
//-------gildanultracotton----------
if (form.gildanultracotton[0].selected){
	Line1_print= "None";
	Line1_flag=0;
}
 if (form.gildanultracotton[1].selected){
	Line1_flag =.99;
	Line1_print="White/Neutral";
}
else if (form.gildanultracotton[2].selected){
	Line1_flag =1.56;
Line1_print="Ash/Sports Grey";
}
else if (form.gildanultracotton[3].selected){
	Line1_flag =1.79;
	Line1_print="All Other Colors";
}
//-------Front Side Colors----------
if (form.front[0].selected){
	Line2_flag=0;
	Line2_print="None";
}
if (form.front[1].selected){
	Line2_flag=.35;
Line2_print="1";
}
if (form.front[2].selected){
	Line2_flag=.50;
Line2_print="2";
}
if (form.front[3].selected){
	Line2_flag=.75;
Line2_print="3";
}
if (form.front[4].selected){
	Line2_flag=.95;
Line2_print="4";
}
//-------Back Side Colors-----------
if (form.backside[0].selected){
	Line3_flag=0;
	Line3_print="None [$0]";
}
if (form.backside[1].selected){
	Line3_flag=1.75;
Line3_print="1";
}
if (form.backside[2].selected){
	Line3_flag=1.95;
Line3_print="2";
}
if (form.backside[3].selected){
	Line3_flag=2.25;
Line3_print="3";
}
if (form.backside[4].selected){
	Line3_flag=2.40;
Line3_print="4";
}
P_Price=Line1_flag+Line2_flag+Line3_flag;
A_Price=P_Price*percent
T_Price=P_Price+A_Price
form.T_Price.value="  $ "+ T_Price;
}
function print(form){
if(!called){
	compute(form);
}
text = ("<HEAD><TITLE>'Cost Esimator'</TITLE></HEAD>");
text = (text +"<BODY BGCOLOR =  '#FFFFFF' ><CENTER><B><FONT SIZE = 3><FONT COLOR=BLUE>Cost Estimator</FONT></FONT></B>");
text= (text +"<br></CENTER>");
text=(text+"<hr>");
text=(text+"<TABLE BORDER =0><TR VALIGN=Top><TD VALIGN=Top>");
text=(text+"<B>Productline1: <BR>Productline2: <BR>Productline3:");
text=(text+"</B></TD><TD>")
text=(text+"<B>"+ Line1_print+"<BR>"+ Line2_print+"<BR>"+ Line3_print+"<BR>");
text=(text+"<TD></TR></TABLE><hr>");
text=(text+"<B><FONT COLOR=RED>Total Cost:</FONT>"+"       $"+T_Price);
text=(text+"<BR><BR><FONT SIZE=-1><FONT COLOR=Gray>To print, choose File and Print.</FONT></FONT>");
text=(text+"</body></html>");
                msgWindow=window.open("","displayWindow","toolbar=no,width=375,height=250,directories=no,status=yes,scrollbars=yes,resize=no,menubar=yes")
                msgWindow.document.write(text)
                msgWindow.document.close()
}
</SCRIPT>



Here's my form:

</script>

<form method="post">
<table cellpadding="4" bgcolor="#EAE8E8">
<tr>
<td>Gildan Ultra Cotton:<br>
  <select name="gildanultracotton">
    <option selected>Select
      <option>White/Neutral
        <option>Ash/Sports Grey
          <option>All Other Colors
      </select></td>
<td>Front Side Colors:<br>
<select name="front">
<option selected>Select
<option>1
<option>2
<option>3
<option>4
</select></td>
<td>Back Side Colors:<br>
<select name="backside">
<option>Select
<option>1
<option>2
<option>3
<option>4
</select></td>
<tr>
<td><br>
<input type="BUTTON" name="Price" value="Update Price" onClick="compute(this.form)">
<input type="text" size="13" name="T_Price" value></td>
<td valign="top"><br>
<input type="BUTTON" name="Print_data" value="Print Preview" onClick="print(this.form)"></td>
</tr>
</table></td>
</tr>
</table>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top