Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2010, 12:13 PM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default 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..





Similar Threads
Thread Thread Starter Forum Replies Last Post
DWH JUNK Dimensions maruthi.vm SQL Server 2005 0 December 14th, 2007 02:42 AM
Property dropdown box in C# code-behind in VS jayaraj123 C# 2005 1 April 5th, 2007 12:54 AM
HOW TO -REG DYNAMIC DROPDOWN BOX.(FIX MY CODE) kaniths Javascript How-To 2 December 21st, 2006 08:44 PM
Modifying The Queries Dialog Box VBA code Ben Horne Access VBA 1 September 26th, 2006 04:22 PM
How do I detect jpeg file dimensions? ruairi ASP.NET 1.0 and 1.1 Basics 2 May 2nd, 2006 03:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.