a code for box dimensions
I am pretty new to Javascript. I have a project I need to do. My formulas involve taking a variable that is put in through a text box and adding different values to it. Javascript is probably an option but I'm not very good with Javascript. The formulas are pretty much addition, but you have to take different values. Basically what it entails is crimping points for a cardboard box for storing books in a library until they can be repaired. I have the length, width and depth and i need to assign crimping points using those values. I have to start with the depth +2, then the next one is the width +7, then depth +3, then width +4, then depth +2, then just the width, but I have to assign total values for them....in other words, if the length is 6, the width is 4 and the depth is 2, I have to put results at 4(D+2), then at 15(W+7), then at 20(D+3), then at 28(W+4), then at 32(D+2), then at 36(W). THEN I have to figure the OTHER side of the box. It is L+3, then D, then L+3, then D+1, then L-3 for the total. In other words, 9(L+3), then at 11(D), then at 20(L+3), then at 23(D+1), then at 26(L-3). It is a little bit over my head right now, but I'm sure it can be done. They are the dimensions of what is called a "phase box" which houses damaged books in a library until preservation can get to them. They start out with a flat piece of stiff cardboard like material. the results of the calculations are points on the flat piece of cardboard that have to be crimped in order top make the box. have a PDF file of the drawing that shows the spots, but I'm not sure i can include it on this forum.Thank you for your help in this. Here is what I have tried, but it doesn't do anything except show the input boxes.
{code]
<html>
<head>
<title>Phase Box Calculator</title>
<script language="javascript" type="text/javascript">
function showDimensions()
{
var length = document.getElementById('length').value;
var width = document.getElementById('width').value;
var depth = document.getElementById('depth').value;
document.getElementById('form_div').style.visibili ty = 'hidden';
document.getElementById('dimensions1').innerHTML = 'Length = ' + length;
document.getElementById('dimensions2').innerHTML = 'Width = ' + width;
document.getElementById('dimensions3').innerHTML = 'Depth = ' + depth;
}
</script>
</head>
<body>
<div id="form_div">
<form id="input_form" action="">
Length:
<input type="text" name="Length" id="length">
<br>
Width :
<input type="text" name="Width" id="width">
<br>
Depth :
<input type="text" name="Depth" id="depth">
<br>
<input type="button" name="click_me" value="Calculate Phase Box" onClick="showDimensions()" />
</div>
<span id="dimensions1"> </span>
<span id="dimensions2"> </span>
<span id="dimensions3"> </span>
<!-- Phase Box Dimensions Here
-->
</form>
</body>
<head>
<title>Phase box dimensions</title>
<script language="javascript">
function calculateDimensions()
{
var variable="length";
//spine length is the length of the book + 3 cm.//
document.write("Spine length cut is ");
document.write(variable+3);
var variable="depth";
//first crimp for the horizontal board//
document.write("First crimp is at ");
document.write(variable+2);
var variable="width";
//second crimp is the width of the book + 5cm//
document.write("Second crimp is at ");
document.write(variable+5);
document.getElementById("Spine length ").innerHTML='Spine length='+ spine length;
document.getElementById("First crimp position").innerHTML='First crimp position'+First crimp position;
document.getElelmentById("Second crimp position").innerHTML='Second crimp position' +Second crimp position;
</head>
<body>
<div id="form_div">
<form id="input_form" action="">
Spine length
<input type="text" name="spine_length" id="Spine length">
<br/>
First crimp position
<input type="text" name="frist_crimp" id="First crimp position">
<br/>
Second crimp position
<input type="text" name="second_crimp" id="Second crimp position">
<input type="button" name="calculate" value="calculate dimensions" onClick="showPhaseBoxDimensions()">
</body>
</html>
[/code]
Last edited by mitch54; January 22nd, 2010 at 05:20 PM..
|