how to create an HTML aquarium voluma calculator?

Discussion in 'HTML & Website Design' started by CarpCharacin, Jan 23, 2015.

  1. #1
    How can i create a HTML aquarium volume calculator so when you put in the dimensions of the tank, it calculates the volume in gallons?
     
    Solved! View solution.
    CarpCharacin, Jan 23, 2015 IP
  2. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #2
    If you have the measurements of the tank, for example in inches, you can calculate the number of gallons.

    For example, lets say you have a tank that is 36" wide, 24" deep, and 24" tall, calculate 36x24x24, which equals 20736 cubic inches. Since each cubic inch equals .004329 gallons, multiply 20736 by .004329, which gives you roughly US 89.77 gallons, or 74.78 UK Gallons.
     
    dwirch, Jan 23, 2015 IP
  3. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #3
    but how would i make an html calculator?
     
    CarpCharacin, Jan 23, 2015 IP
  4. #4
    In HTML, you wouldn't. You'd most likely use javascript to do it. Here is a quick and dirty one, which should get you to a starting point (Demo Here):
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://www.fishlore.com/scripts/js/share.js"></script>
    <script type="text/javascript">
     var result = 0;
     var roundLength = 2;
    
      function computeGallons()
     {
        result = Math.round((document.frmMain.TankLength.value * document.frmMain.TankWidth.value * document.frmMain.TankHeight.value / 231)*100)/100;
        document.frmMain.USGallons.value = Math.round(result*100)/100;
        document.frmMain.UKGallons.value = Math.round((result * 0.833)*100)/100;
     }
    
    </script>
    <form name="frmMain"><span class="b">Aquarium Calculator: Calculate Rectangle Fish Tank Volume in Gallons Based on Tank Size</span><p>
       
            Fish Tank Length in Inches:<br />
            <input type="text" name="TankLength" onkeyup="computeGallons()"><br />
            <br />
            Fish Tank Width in Inches:<br />
            <input type="text" name="TankWidth" onkeyup="computeGallons()"><br />
            <br />
            Fish Tank Height in Inches:<br />
            <input type="text" name="TankHeight" onkeyup="computeGallons()"><br />
            <br />
            Aquarium Size is<br />
            <input type="text" name="USGallons"> US Gallons<br />
            <br />
            Aquarium Size is<br />
            <input type="text" name="UKGallons"> UK Gallons<br />
       
    </form>
    
    
    Code (markup):
     
    dwirch, Jan 23, 2015 IP
  5. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #5
    Note that I am no javascript guru; I rarely use it. So, there may be extraneous things in here that are not needed.
     
    dwirch, Jan 23, 2015 IP
  6. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #6
    ok so this is where i have it set up: http://www.utahfishkeepers.us/page/volumecalculator
     
    CarpCharacin, Jan 23, 2015 IP
  7. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #7
    Great! glad it is working for you.
     
    dwirch, Jan 24, 2015 IP