# How to add a calculator to my site?



## Jason0218 (Jan 12, 2010)

I am using Dreamweaver CS3. I wand to add a calculator to my site. I have found a couple of calculators that I like but when I add them the do not calculate. I even went as far as contacting the author of the calculator. He gave me permission and also gave me the code in Javascript. But I can not get it to work. I tried to contact the author again and was told he wasn't familular with D.W. CS3. So now I am here. If any body has any ideas on how to build a caclulator using D.W. CS3 or can offer some help in getting the code that I already have to work. :4-dontkno:4-dontkno


----------



## Slapshot (Feb 3, 2008)

You can just google "calculator script" or something like that.


----------



## Jason0218 (Jan 12, 2010)

No I can't. I want to use a specific calulator. Google doesn't have one. I would like to just make it part of the web page so it blends in.
I need to put up a board foot calculator. its for calculating board foot for rough cut lumber.
Thanks


----------



## Slapshot (Feb 3, 2008)

Give me the formula, I'll whip up a quick script in PHP for you.


----------



## dm01 (Oct 10, 2006)

JavaScript would be better IMO, make the user do their own bloody work for a change. [PHP uses server power, possibly leading to higher-than-necessary bandwidth costs. JavaScript uses the user's computer power, leading to no other bandwidth costs. JavaScript is also a little bit quicker.]



> How do I calculate board feet?
> 
> One board foot is the nominal quantity of lumber derived from a piece of rough green lumber 1 inch thick and 1 foot wide by 1 foot long. In other words a board foot is the nominal thickness times the nominal depth in inches divided by 12 time the length in feet. For example a 10 foot 2 x 6 would work out to be 10 board feet.
> 
> ...


http://www.cwc.ca/Resources/E-Tools/BoardCalc.htm

What they did is complex, do you need something this fancy? There a couple of stability and sensibility improvements I can think of from just playing around with this.


----------



## Jason0218 (Jan 12, 2010)

I have the code in javascript. The issue is when you click on the calculate button nothing happens. I am trying to use DW CS3 I have tried a couple of different ways and I still end up with the same issue. 

You have the correct formula. I just need something simple. But I need something that will work with out too much hassle.


----------



## Jason0218 (Jan 12, 2010)

Here is the calculator that I was given the code to. 

http://metrology.burtini.ca/calc_wood.html


Like I said I have the code for the calculator only directly from the author of this calculator. I have tried just insterting the javascript. But I get absolutely nothing when I copy and paste the javascrip onto a blank .html page. I have also tried to Copy and Paste in Design mode and I the calculator the reset button works fine but the Calculate button does nothing. I didn't think javascript need a server application to work I have played with it and I have had no luck. The only thing I can think is I am missing a step or maybee it just won't work. At this point not sure anymore.


----------



## dm01 (Oct 10, 2006)

May we have a link to the relevant page, or the source from the page (within

```

```
)? It is difficult to divine what you have done without this information.


----------



## Jason0218 (Jan 12, 2010)

Okay,
Here is the page.

http://www.ni-computer.com/testcalc.html

I have four (4) different calculators on this page. The bottom one is the one I would like to get to work. That is also the one that I have the exact code for directly from the author.


----------



## dm01 (Oct 10, 2006)

You are missing a whole bunch of the calculator. What you have is the basic form, you need the JavaScript to calculate the numbers that you need.


```
<script type="text/javascript">

<!-- Conversion calculators
// Author		: APLJaK Ventures ([email protected])
// for		: Metrology 101
// Date		: 2007 ver 2.00_2007
// Function		: calculates Boardfeet for Hardwoods
// problems	: none known
// ---------------------------------------------
// written by	: APLJaK Ventures 
// email		: [email protected]
// website		: http://metrology.burtini.ca/
// coyright		: © 2001-2007 - All Rights Reserved
// This copyright notice must remain intact
// Please feel free to link to this page. If you would prefer to use the script the copyright notice must remain intact.
//APLJaK Ventures also requests a link from your site to ours. This link is already included in the visible copyright.
// It would be nice to credit the author somewhere on your page ;-)
//
// PLEASE DO NOT REMOVE THESE LINES FROM DOCUMENT -->
//-->


<!-- Hide JavaScript

function Array() {
	this.length = Array.arguments.length;
	for (var i = 0; i < this.length; i++) {
	this[i] = Array.arguments[i];
	}
}

convtable = new Array();
convtable[0] = "12";			<!-- 12 inches in 1 FOOT -->
convtable[1] = "1";			<!-- Base Unit inches -->
convtable[2] = "39.3700787";		<!-- 39.37 inches in 1 METRE -->
convtable[3] = "3.93700787";		<!-- 3.937 inches in 1 DECIMETRE -->
convtable[4] = "0.393700787";		<!-- 0.393 inches in 1 CENTIMETRE -->
convtable[5] = ".25";			<!-- 0.250 inches in 1 QUARTER inch --> 

function roundoff(outval) {

	val = "";
	val += outval;
	ps1 = val.indexOf(".");
	if (ps1 > -1){
		outval = outval + 0.0000001
		outval = val.substring(0,ps1 + 3)
		}
	return outval
}

function cordcalc() {

var T = 0				<!-- variable THICKNESS -->
var W = 0				<!-- variable WIDTH     -->
var L = 0				<!-- variable LENGTH    -->

var I2C = 2.54				<!-- variable inches to cm -->


<!-- pick units for thickness -->
for (var a = 0; a < document.cordcal.Tunits.options.length; a++) {
	if (document.cordcal.Tunits.options[a].selected) {
	T = a;
		}
	}
<!-- pick units for width -->
for (var a = 0; a < document.cordcal.Wunits.options.length; a++) {
	if (document.cordcal.Wunits.options[a].selected) {
	W = a;
		}
	}
<!-- pick units for length -->
for (var a = 0; a < document.cordcal.Lunits.options.length; a++) {
	if (document.cordcal.Lunits.options[a].selected) {
	L = a;
		}
	}

// get user input and correct for blanks by entering a value of 1
<!-- user input for thickness -->
usert = document.cordcal.thick.value;
if (usert == 0){
	usert = 1;
	document.cordcal.thick.value = usert;
	}
<!-- user input for width -->
userw = document.cordcal.width.value;
if (userw == 0){
	userw = 1;
	document.cordcal.width.value = userw;
	}
<!-- user input for length -->
userl = document.cordcal.length.value;
if (userl == 0){
	userl = 1;
	document.cordcal.length.value = userl;
	}


<!-- convert user input into cubic inches -->
imp = ((usert * convtable[T]) * (userl * convtable[L]) * (userw * convtable[W]));
<!-- round off results -->
imp = roundoff(imp);
<!-- fill variable [impout] with results -->
document.cordcal.impout.value = imp + " cubic inches";

<!-- convert user input into cubic cm -->
met =  (((usert * convtable[T]) * I2C) * ((userl * convtable[L]) * I2C) * ((userw * convtable[W]) * I2C));
<!-- round off results -->
met = roundoff(met);
<!-- fill variable [metout] with results -->
document.cordcal.metout.value = met + " cubic cm.";


<!-- Board Foot = Cubic Inches / 144 -->
boardfoot = (imp/144);
<!-- round off value for Board Foot -->
boardfoot = roundoff(boardfoot);
<!-- fill variable [legout] with results -->
document.cordcal.legout.value = boardfoot;
}


// End Hiding -->
</script>

<body>

<font face="arial" size=3>

</font>
<table cellspacing="1" tableborder="3" border="3" bgcolor="#F5F5F5">
<form name="cordcal" title="Board Foot Calculator, by APLJaK Ventures">
<!-- adapted from Cord Wood Calculator by APLJaK Ventures -->

<tr>
	<td colspan="12">
	<font style="color: #3333cc font-family: "Arial", sans-serif; text-size: 3">Board Foot Calculator</font>
	<a href="http://metrology.burtini.ca/" target="_blank"><font color="#bbbbbb" face="arial" size="1">  by APLJaK</font></a>
	</td>
	
</tr>
<tr>
	<td colspan="2" align="center" width="" title="Enter board thickness">
		<font face="arial" size="2" color="#000000">
		Enter Thickness<br>
		<input type="text" name="thick" size="3" value=""  onChange="cordcalc();" onmouseover="window.status='Enter Board Thickness';return true"
onmouseout="window.status='';return true">
</td>
<td colspan=1 width="100">
		<font face="arial" size="2" color="#000000">
		units<br>
		<select name ="Tunits" size="1" onchange="cordcalc();"
onmouseover="window.status='Select Units - 1/4s is Quarters of an Inch';return true"
onmouseout="window.status='';return true">

			<option>ft</option>
			<option selected>in</option>
			<option>m</option>
			<option>dm</option>
			<option>cm</option>
			<option>1/4's</option>
		</select>
		</font>
	</td>

	<td colspan=2 align="center" width="" title="Enter board width">
		<font face="arial" size="2" color="#000000">
		Enter Width<br>
		<input type="text" name="width" size="5" value="" onChange="cordcalc();"
onmouseover="window.status='Enter Board Width';return true"
onmouseout="window.status='';return true">
</td>
<td colspan=1 width="">
		<font face="arial" size="2" color="#000000">
		units<br>
		<select name ="Wunits" size="1" onchange="cordcalc();"
onmouseover="window.status='Select Units';return true"
onmouseout="window.status='';return true">

			<option>ft</option>
			<option selected>in</option>
			<option>m</option>
			<option>dm</option>
			<option>cm</option>
			
		</select>
		</font>
	</td>

	<td colspan=2 align="center" width="" title="Enter board length">
		<font face="arial" size="2" color="#000000">
		Enter Length<br>
		<input type="text" name="length" size="5" value="" onChange="cordcalc();"
onmouseover="window.status='Enter Board Length';return true"
onmouseout="window.status='';return true">
<td colspan=1 width="">
		<font face="arial" size="2" color="#000000">
		units<br>

		<select name ="Lunits" size="1" onchange="cordcalc();"
onmouseover="window.status='Select Units';return true"
onmouseout="window.status='';return true">

			<option selected>ft</option>
			<option>in</option>
			<option>m</option>
			<option>dm</option>
			<option>cm</option>
			
		</select>
		</font>
	</td>

</tr>
<tr>
	<td colspan="2">
		<center>
		<input type="button" value="Calculate" title="Calculate Board Foot" onClick="cordcalc();"
onmouseover="window.status='Calculate Total Board Feet';return true"
onmouseout="window.status='APLJaK Ventures';return true">

		</center>
	</td>
	<td colspan="10">
		<input type="text" name="impout" title="cubic inches"      value="" onClick="cordcalc();" onmouseover="window.status='Total Volume of Lumber in cubic inches';return true"
onmouseout="window.status='';return true"><br>
		<input type="text" name="metout" title="cubic centimeters" value="" onClick="cordcalc();" onmouseover="window.status='Total Volume of Lumber in cubic centimeters';return true"
onmouseout="window.status='';return true"><br>	
	</td>
</tr>
<tr>
	<td colspan="2">
		<center><INPUT TYPE="reset" VALUE="Clear Form" title="Clear all entries." onmouseover="window.status='Reset all fields to default values';return true"
onmouseout="window.status='';return true">
</center>

	</td>
	<td colspan="10" title="Board Feet of Lumber received">
		<font face="arial" size="2" color="#000000">
		You received:<br>
		<input type="text" name="legout" value="" onClick="cordcalc();" 
onmouseover="window.status='Total Volume of Lumber in Board Feet';return true"
onmouseout="window.status='';return true">
		Board Feet<br> (Net Tally)
		</font>
	</td>
</tr>
</form>
</table>
```


----------



## Jason0218 (Jan 12, 2010)

Thanks alot. That worked. Perfectly

I think its time I sit down and figure out Javascript and learn how to code properly.


----------



## Jason0218 (Jan 12, 2010)

I do have one quick question do you recommend a book or a place to learn Javascript?

Thanks Again


----------



## dm01 (Oct 10, 2006)

Glad to hear it.

http://www.w3schools.com/js/default.asp is always useful. Books go out of date quickly.


----------



## san4os (Jan 18, 2010)

Hi!

use jquery calculator!!! http://keith-wood.name/calculator.html

______________
discount coffee


----------

