Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic 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 12th, 2010, 11:35 AM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default the rookie is back with a question

I have a project that I need to do that involves formulas...I think. I have to do a page that will take the input of length, width and depth and return several positions for folds on a box. I've got the input boxes to work but I'm not sure where to go from there. I have a position that is the depth plus 2 inches, then the next one from there is the width plus 7 inches, the next one is the depth plus 3 from there and so on. The problem is I'm not sure how to get the results to work in the formulas...like the depth plus 2, then the width plus 7 from there.....any suggestions? I hope in the near future to be a little more knowledgeable about programming, as I start a 400 level web programming class next week...wish me luck!!
 
Old January 13th, 2010, 10:28 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I, for one, haven't the foggiest notion what your actual problem is.

In any case, if it involves calculations, then HTML won't help you, at all.

Possibly you could do it with Javascript--probably, in fact--but you don't say if that's an option. Or you could do it with server-side technology (ASP/JSP/PHP/etc.).

But in any case, if you don't show us the formulas, we can't possibly tell you how to code them.
And if you don't tell us what language you will code in, we would be guessing in the dark.
The Following User Says Thank You to Old Pedant For This Useful Post:
mitch54 (January 14th, 2010)
 
Old January 14th, 2010, 10:41 AM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default

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. 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.visibility = '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>
 
Old January 16th, 2010, 12:21 PM
Authorized User
 
Join Date: Nov 2009
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to msherburne84
Default

Before I write a solution to this I just want to be sure that I understand what it is your doing. Correct me if I'm wrong. Your trying to get values of a box, width, length, and depth? Then adding some values to these dimensions and returning them to the client?
The Following User Says Thank You to msherburne84 For This Useful Post:
mitch54 (January 18th, 2010)
 
Old January 19th, 2010, 10:15 AM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default

that's right...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. i have a PDF file of the drawing that shows the spots, but i'm not sure i can include it on this forum.
 
Old January 22nd, 2010, 10:40 AM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default

I can still use help on this, if anyone can help me. Thanks.
 
Old March 12th, 2010, 06:16 PM
Authorized User
 
Join Date: Nov 2009
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to msherburne84
Default

sorry its taken awhile to get back to you but if you still need help let me know I should be able to write something up quick and easy for you that should get you started. Another problem I have understanding is the actual formula. The way you wrote it above "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)" You don't use the width and for instance in the last formula you are take 3 from the Length and multiplying that by 26. If you could be a little more specific on the formula. Tell me what the Length, Width and Depth need to do.

Last edited by msherburne84; March 12th, 2010 at 07:28 PM..
 
Old March 15th, 2010, 10:58 AM
Authorized User
 
Join Date: Oct 2009
Posts: 14
Thanks: 5
Thanked 2 Times in 2 Posts
Default

thank you for getting back to me. this is a formula for making the dimensions of a box to store books in. the L, W, and D are the dimensions of the book. they need to crimp the cardboard at certain dimensions to fit the book. the page needs to show the spots to make the crimps. each one of those spots has to have a dimension to it. there is a vertical board and a horizontal board. if there was a way to include attachments i could attach a drawing of what they need. let me try to explain....the first crimp needs to come at the point that is the depth Plus 2 inches. the second crimp is the width plus 7 inches FROM THE FIRST CRIMP....that's the part that is throwing me off...ok, let me use some numbers as examples.
L=215
W=137
d=42
the first crimp would come at 44(D+2), the next crimp would come at 186(44+(W+5)), then next crimp at 231(186+(D+3)), then 372(231+(W+4)), then 416(372+(D+2)) and the final one would be at 553(416+W)
does that make sense now? that is the horizontal board. the vertical board is
210(L-5), then 252(210+D), then 467(252+L), then 510(467+(D+1)) and finally 722(510+(L-3))
if you can show me how to put these in a form that can be displayed on a webpage it would be greatly appreciated. i am doing a class now that's a little over my head and i am struggling with it. this one just kind of baffles me.....i can't figure out why i can't get it to work...i should know this, but i guess my brain went to sleep in class that day!!! thanks for any and all of the help you can give me!!!!!
 
Old March 19th, 2010, 10:35 AM
Authorized User
 
Join Date: Nov 2009
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to msherburne84
Default

Its a good thing I checked this post I thought I already responded to you.
I you could email me that pdf document that will make it a lot easier. Sorry it took me a while to figure I didn't respond.


Last edited by msherburne84; April 5th, 2010 at 08:02 AM..
 
Old April 4th, 2010, 10:47 PM
Authorized User
 
Join Date: Nov 2009
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to msherburne84
Default

This is what I came up with I really hope this helps you again I'm very sorry it took me forever to get back to you work has been really crazy. If you have any questions please feel free to ask.
Also with what you posted for the formula in your last post there were some differences between that and the paper that you emailed me, such as: crimp 2 of horizontal box and just about all of the vertical box. So I used what was on the paper.
Mike
Code:
<!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">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Box Dimensions</title>
        
        <script type="text/javascript">
            function calcCrimps() {
                var depth = parseInt(document.getElementById('depth').value);
                var width = parseInt(document.getElementById('width').value);
                var length = parseInt(document.getElementById('length').value);

                var horizontalElement = horizontalCrimps(depth, length, width);
                var firstP = document.createElement('p');

                document.getElementById('result').appendChild(firstP);
                document.getElementById('result').firstChild.innerHTML = horizontalElement;

                var secondP = document.createElement('p');
                var verticalElement = verticalCrimps(depth, length, width);
                document.getElementById('result').appendChild(secondP);
                document.getElementById('result').lastChild.innerHTML = verticalElement;
            }

            function horizontalCrimps(Depth, Length, Width) {
                var lengthOfBoard = Length + 3;
                var crimp1 = Depth + 2;
                var crimp2 = crimp1 + (Width + 7);
                var crimp3 = crimp2 + (Depth + 3);
                var crimp4 = crimp3 + (Width + 4);
                var crimp5 = crimp4 + (Depth + 2);
                var totalWidth = crimp5 + Width;

                var contentString = "The length of the horizontal board is " + lengthOfBoard + "<br />1st Crimp: " + crimp1.toString() + "<br />2nd Crimp: " + crimp2.toString() + "<br />3rd Crimp: " + crimp3.toString() + "<br />4th Crimp: " + crimp4.toString() + "<br />" + "5th Crimp: " + crimp5.toString() + "<br />Total Width: " + totalWidth.toString();                

               return contentString;

           }

           function verticalCrimps(Depth, Length, Width) {
               var crimp1 = Length + 3;
               var crimp2 = crimp1 + (Depth);
               var crimp3 = crimp2 + (Length + 3);
               var crimp4 = crimp3 + (Depth + 1);
               var totalLength = crimp4 + (Length - 3);
               var widthOfBoard = Width;

               var contentString = "Vertical Board " + "<br />1st Crimp: " + crimp1.toString() + "<br />2nd Crimp: " + crimp2 + "<br />3rd Crimp: " + crimp3 + "<br />4th Crimp: " + crimp4 + "<br />Total Length: " + totalLength + "<br />Width: " + Width;

               return contentString;
           }

        </script>
                               
    </head>
    
    <body>
        <h1>Phase Box Dimensions</h1>
        <form name="mainForm" id="boxDimensions" action="box.html">
            <div>
                <label>Depth &nbsp;</label>
                <input id="depth" type="text" />
                <br />
            </div>
            
            <div>
                <label>Width &nbsp;</label>                        
                <input id="width" type="text" />
                <br />
            </div>
            
            <div>
                <label>Length&nbsp;</label>
                <input id="length" type="text" />
            </div>
            <br />
            <br />
            <label>Result</label>
            <div id="result"></div>

            <input type="button" value="Calculate Crimps" onclick="calcCrimps()" />
        </form>
    
    </body>
</html>

Last edited by msherburne84; April 5th, 2010 at 08:02 AM..
The Following User Says Thank You to msherburne84 For This Useful Post:
mitch54 (April 5th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rookie question mitch54 HTML Code Clinic 3 April 7th, 2010 01:18 PM
Help PHP Rookie Stuck Chapter 1! shinigami BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 3 November 14th, 2009 12:45 AM
Small rookie question maximus101 VB Databases Basics 1 February 23rd, 2006 11:51 PM
Rookie question: container div not containing CFGerry BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 6 September 1st, 2005 09:00 PM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM





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