Results 1 to 2 of 2

Thread: javascript calulator code help

  1. #1
    Join Date
    Feb 2011
    Posts
    10

    javascript calulator code help

    For some reason I can get this to work on my other calculators forms but sometimes it doesn't work. here is the code for the one that doesn't work.

    here is the script:
    Code:
    <script language="JavaScript">
    <!--
    //Script by Tom Richardson Jr.
    //Permission to use this scipt is permited as long as this
    //part stays intact. 
    //If you have any questions, e-mail me at gooftroop@geocities.com
    //or visit my website at http://home.rmci.net/gooftroop
    //This is just a basic calculator that will do the exponential math.
    //Or, in basic terms, will calculate powers of any given number.
    //Just another user-friendly calculator that uses terms and text
    //fields. 
    //Have fun!!
    function calc() {
    		Pi = 3.1415926535;
            a = document.form1.a.value;
            b = document.form1.b.value;
    		c = document.form1.b2.value
            d = Pi * (a*a)/4;
    		e = (b)/231;
    		f = (d * e);
            document.form1.total.value = f;
    		        		
            a2 = document.form1.a.value;
            b2 = document.form1.b2.value;
            c2 = Pi * (a2*a2)/4;
    		d2 = Pi * (b2*b2)/4;
    		e2 = (c2 - d2);
            document.form1.total2.value = e2;
    		f2 = document.form1.total2.value;		
            g2 = document.form1.b.value;
            h2 = (f2 * g2)/231;		
            document.form1.total222.value = h2		
            }
    //-->
    </script>
    here is the form code
    Code:
                              <form name="form1">
        <center>
              <table border=2 cellspacing=1 cellpadding=1 width="311" height="343" bordercolorlight="#FF6633" bordercolordark="#CC3333">
    
                <tr bgcolor="#FFCC99"> 
                  <td colspan=3 align=center height="40"><font face="Times New Roman, Times, serif" size="3" ><b><h4>Hydraulic 
                    Pump and Motor Displacement in Cubic Inches per Minute</h4></b></font></td>
            <tr> 
              <td height="255" width="94"> 
                <div align="center"><font size="2"><b>Enter GPM<br>
                  <input type="text" name="a" size=15 maxlength="15">
                  <br>
                  </b></font><br>
                  <b><font size="2">Enter RPM<br>
    
                  </font></b> 
                  <input type="text" name="b" size=15 maxlength="15">
                </div>
              </td>
              <td height="255" width="76"> 
                <div align="center"><br>
                  <br>
                  <input type="button" value="Calculate" onClick="calc()" name="Calculate"><br><br>
                   <input type="reset" value="Reset" name="reset">
                </div>
              </td>
    
              <td height="255" width="118"> 
                <div align="center"><font size="2"><b>Displacement in<br>
                  CIR</b></font><br>
                  <input type="text" name="total" size=15 maxlength="15">
                </div>
              </td>
                <tr bgcolor="#FFCC99"> 
                  <td colspan=3 align=center height="6"> 
                   
    
              </td>
          </table>
        </center>
      </form>
    I don't understand why it will work for other form calculators I have ? It is the same code on the other ones like the one above?

    Thanks

  2. #2
    Join Date
    Feb 2011
    Posts
    10
    figure it out took me forever but was using the wrong script

Similar Threads

  1. Javascript code to submit the page does not work sometimes in IE
    By SantoshKS in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 02 Dec 2010, 12:25 AM
  2. Javascript duplicate code
    By Faldwin in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 15 Jul 2009, 01:48 PM
  3. HTML or Javascript code to control tables
    By calcoast in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 07 Aug 2007, 07:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •