SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for a real newbie

    I am trying to get the final result of my calculations to have comma's in the numerical answer. Also Why am I getting a neg number as my answer? Take a look if you wouldn't mind and let me know if you have any ideas.
    All js and html below:
    <!-- CALCULATOR -->
    <html>
    <head>
    <title>MCF Calculator</title>

    <script language="JavaScript">

    function CalculateSum(Atext, Btext, Ctext, Dtext, Etext, Ftext, form)
    {
    var A = parseFloat(Atext);
    var B = parseFloat(Btext);
    var C = parseFloat(Ctext);
    var D = parseFloat(Dtext);
    var E = parseFloat(Etext);
    var F = parseFloat(Ftext);

    form.Answer.value= Math.round((A * 30 * B)* (C/100 -1)* (D/100 -1) * (E/100 -1) + F);


    }

    function ClearForm(form)
    {
    form.input_A.value = "";
    form.input_B.value = "";
    form.input_C.value = "";
    form.input_D.value = "";
    form.input_E.value = "";
    form.input_F.value = "";
    form.Answer.value = "";

    }

    </script>


    </head>
    <body text="white" bgcolor="#990000" background="">



    <p><center><font size="+2"> MCF Calculator</font></center>
    <center>
    <hr style="WIDTH: 100%; HEIGHT: 11px" width="100%" color="#008000" size="11"></center><font size="5">
    <center>
    <table height="320" width="956" align="left" border="0">

    <tr><!-- Row 1 -->
    <td>
    <div align="center">

    <form name="Calculator" method="post">
    <p align="left">******
    Total Daily Production**<input style="HEIGHT: 25px" size="4" name="input_A">*<font size="1">(All
    Wells)<br><br></font>*********************Price
    Per*Unit* <input style="HEIGHT: 25px" size="4" name="input_B">*<font size="1">(MCF)<br><br></font>**********
    State
    Severance Tax* <input style="HEIGHT: 25px" size="4" name="input_C">*%<font size="1"><br></font><br>****************************
    ** *LORI** <input style="HEIGHT: 25px" size="4" name="input_D">*% <font size="1">(Land Owner
    Royalty)<br></font><br>******************************
    * ORRI** <input style="HEIGHT: 25px" size="4" name="input_E">*% <font size="1">(Overwrite
    Royalty)<br><br></font>***************
    Field Expenses*<font size="4"><strong>$ </strong></font>
    <input style="HEIGHT: 25px" size="4" name="input_F">*<font size="1">(Monthly Supervision and
    Maintainence)<br><br><br><br>**************************************************
    <input style="WIDTH: 189px; HEIGHT: 28px" onclick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form.input_C.value, this.form.input_D.value, this.form.input_E.value, this.form.input_F.value, this.form)"type="button" size="34" value="Click Here to Calculate" name="AddButton"><br></font><br>**************
    Net Profit * =* <input size="9" name="Answer" style="WIDTH: 108px; HEIGHT: 25px">*(Per Month)<br><br><br><br>****************************************
    *<input type="button" value="Reset" name="ClearButton" onclick="ClearForm(this.form)" style="WIDTH: 102px; HEIGHT: 28px" size="16"></p>
    </form></div><br></td><!-- Col 1 --></tr></table></center>





    </body>
    </html>

  2. #2
    SitePoint Wizard jimbo_dk's Avatar
    Join Date
    May 2005
    Location
    Singapore
    Posts
    1,261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this line of code below your calculation.

    Code JavaScript:
    var s = (A * 30 * B) + '\n X ' + (C/100 -1) + '\n X ' + (D/100 -1) + '\n x' + (E/100 -1) +'\n 
     
    + ' + F + '\n = ' + Math.round((A * 30 * B)* (C/100 -1)* (D/100 -1) * (E/100 -1) + F);
    alert(s);

    It'll show you the steps. Basically I think what's wrong are these calcs: (C/100 -1) This would always bring about a negative value.
    Last edited by jimbo_dk; Jul 9, 2007 at 16:53. Reason: made a mistake...
    Winners Respond. Losers React.
    Singapore Web Designer

  3. #3
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would it be C or D less than 100 makes the result to neg.???

  4. #4
    SitePoint Wizard jimbo_dk's Avatar
    Join Date
    May 2005
    Location
    Singapore
    Posts
    1,261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by carson1185 View Post
    would it be C or D less than 100 makes the result to neg.???
    Yups. Same applies for C, D, E.
    Winners Respond. Losers React.
    Singapore Web Designer


Bookmarks

Posting Permissions

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