Results 1 to 12 of 12

Thread: how to add a simple calculation
      
   

  1. #1
    dcourt is offline Private
    Join Date
    May 2008
    Posts
    1

    Default how to add a simple calculation

    I don't have a lot of experience with this. I am trying to add a few formulas to my website but dont know how.

    ex.

    1st Balance = 40,000 (user types this in)

    2nd Balance = 20,000 (user types this in)

    Total balance = 60,000

    this would be an addition of the 1st balance and the 2nd balance

  2. #2
    Join Date
    Feb 2006
    Location
    Earth
    Posts
    8,721

    Default Re: how to add a simple calculation

    Would a calculator on the page do the trick, or is there more involved.

  3. #3
    Tash717 is offline Private
    Join Date
    Apr 2008
    Posts
    1

    Default Re: how to add a simple calculation

    I work with dcourt, and what he is trying to do is add two cells together based on different inputs, so someone visiting his site could calculate the total themselves.

    Example:
    1st balance:

    $20,000
    2nd balance$10,000 Total:$30,000 (we want this cell to automatically calculate the values above).


    A simple calculator would work...is there a tool in BlueVoda that will help us, or can we import an excel formula? If we need a claculator, where would we find it?

    Thanks!

  4. #4
    CarbonTerry's Avatar
    CarbonTerry is offline Major General
    Join Date
    Oct 2005
    Location
    St L MO
    Posts
    2,590

    Default Re: how to add a simple calculation

    Paste the below code into an html box for an online calculator.


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Untitled Page</title>
    <meta name="GENERATOR" content="Created by BlueVoda">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <div id="bv_" style="position:absolute;left:39px;top:30px;width: 150px;height:150px;z-index:0" align="left">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Untitled Page</title>
    <meta name="GENERATOR" content="Created by BlueVoda">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <div id="bv_" style="position:absolute;left:39px;top:30px;width: 150px;height:150px;z-index:0" align="left">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Untitled Page</title>
    <meta name="GENERATOR" content="Created by BlueVoda">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <div id="bv_" style="position:absolute;left:34px;top:34px;width: 150px;height:150px;z-index:0" align="left">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="stylesheet" href="/src/css.css" type="text/css">

    <style>
    <!--
    .btnBlue {
    background-color:CCD3DC;
    border-color:DCE2E9;
    color:19222D;
    font-size : 11px;
    font-family : verdana,arial,helvetica,sans-serif;
    }
    .btnLtBlue {
    background-color:EEEFF1;
    border-color:DCE2E9;
    color:19222D;
    font-size : 11px;
    font-family : verdana,arial,helvetica,sans-serif;
    }
    .btnWhite {
    background-color:ffffff;
    border-color:DCE2E9;
    color:19222D;
    font-size : 11px;
    font-family : verdana,arial,helvetica,sans-serif;
    }
    -->
    </style>
    <script language="JavaScript">
    <!--
    var ci;
    function init() {
    ci = document.calc.input;
    }
    function calculate() {
    ci.value = eval(ci.value);
    }
    function plus() {
    ci.value += '+';
    }
    function minus() {
    ci.value += '-';
    }
    function mult() {
    ci.value += '*';
    }
    function div() {
    ci.value += '/';
    }
    function decimal() {
    ci.value += '.';
    }
    function openp() {
    ci.value += '(';
    }
    function closep() {
    ci.value += ')';
    }
    function num(x) {
    ci.value += x;
    }
    function recip() {
    ci.value = 1/(ci.value);
    }
    function square() {
    ci.value = (ci.value)*(ci.value);
    }
    function cube() {
    ci.value = (ci.value)*(ci.value)*(ci.value);
    }
    function pi() {
    ci.value += Math.PI;
    }
    function plus_or_minus() {
    ci.value *= -1;
    }
    function percent() {
    ci.value *= .01;
    }
    function sqrt() {
    ci.value = Math.sqrt(ci.value);
    }
    function power() {
    var np = prompt("What power do you want? Must be a number!","")
    ci.value = Math.pow(ci.value, np);
    }
    function cos() {
    ci.value = Math.cos(ci.value);
    }
    function sin() {
    ci.value = Math.sin(ci.value);
    }
    function tan() {
    ci.value = Math.tan(ci.value);
    }
    function Round() {
    ci.value = parseInt(ci.value);
    }
    function del() {
    ci.value = ci.value.substring(0, ci.value.length - 1)
    }
    // -->
    </script>

    </head>
    <body onload="init()" leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" bgcolor="#ffffff" text="#000000" link="#006666" vlink="#006666" alink="#ff00ff" background="">
    <div align="center">

    <table class="table1" cellpadding="40" cellspacing="0" border="0">
    <tr>
    <td valign="top" align="center" style="padding-top:30px;padding-bottom:30px">


    <table bgcolor="000000" cellpadding="2" cellspacing="0" border="0">
    <form name="calc">
    <tr>
    <td>
    <table bgcolor="888E96" width="55" height="65" cellspacing="0" cellpadding="5" border="1">
    <tr>
    <td><input type="text" name="input" size="20" maxlength="30"></td>
    <td><input type="button" value=" ^ " onClick="power()" class="btnLtBlue"></td>
    <td><input type="button" value="Del" onClick="del()" class="btnLtBlue"></td>
    <td><input type="button" value=" C " onClick="ci.value = ''; " class="btnLtBlue"></td>
    </tr>
    <tr>
    <td nowrap="1"><input type="button" value=" 1 " class="btnBlue" onClick="num(1)">
    <input type="button" value=" 2 " class="btnBlue" onClick="num(2)">
    <input type="button" value=" 3 " class="btnBlue" onClick="num(3)">
    <input type="button" value=" ( " class="btnLtBlue" onClick="openp()"></td>
    <td><input type="button" value=" + " onClick="plus()" class="btnLtBlue"></td>
    <td><input type="button" value="sqrt" onClick="sqrt()" class="btnLtBlue"></td>
    <td><input type="button" value="Cos" onClick="cos()" class="btnLtBlue"></td>
    </tr>
    <tr>
    <td nowrap="1"><input type="button" value=" 4 " class="btnBlue" onClick="num(4)">
    <input type="button" value=" 5 " class="btnBlue" onClick="num(5)">
    <input type="button" value=" 6 " class="btnBlue" onClick="num(6)">
    <input type="button" name="closeprth" value=" ) " class="btnLtBlue" onClick="closep()"></td>
    <td><input type="button" value=" - " onClick="minus()" class="btnLtBlue"></td>
    <td><input type="button" value=" 1/x" class="btnLtBlue" onClick="recip()"></td>
    <td><input type="button" value="Sin " onClick="sin()" class="btnLtBlue"></td>
    </tr>
    <tr>
    <td nowrap="1"><input type="button" value=" 7 " class="btnBlue" onClick="num(7)">
    <input type="button" value=" 8 " class="btnBlue" onClick="num(">
    <input type="button" value=" 9 " class="btnBlue" onClick="num(9)">
    <input type="button" value=" % " onClick="percent()" class="btnLtBlue"></td>
    <td><input type="button" value=" * " onClick="mult()" class="btnLtBlue"></td>
    <td><button class="btnLtBlue" onClick="square()">&nbsp;x<sup>2</sup>&nbsp;</button></td>
    <td><input type="button" value="Tan " onClick="tan()" class="btnLtBlue"></td>
    </tr>
    <tr>
    <td nowrap="1"><input type="button" value=" 0 " class="btnBlue" onClick="num(0)">
    <input type="button" value=" . " class="btnBlue" onClick="decimal()">
    <input type="button" value=" +/- " onClick="plus_or_minus()" class="btnLtBlue">
    <input class="btnLtBlue" type="button" value=" Pi " onClick="pi()"></td>
    <td><input type="button" value=" / " onClick="div()" class="btnLtBlue"></td>
    <td><button class="btnLtBlue" onClick="cube()">&nbsp;x<sup>3</sup>&nbsp;</button></td>
    <td><input type="button" value=" = " class="btnWhite" onClick="calculate()"></td>
    </tr>
    </table>
    </td>
    </tr>
    </form>
    </table>



    </td>
    </tr>
    </table>
    </div>
    <div align="center">
    <p />
    <p />
    <script type="text/javascript"><!--
    google_ad_client = "pub-0616514424695237";
    google_ad_width = 100;
    google_ad_height = 90;
    google_ad_format = "120x90_0ads_al";
    google_ad_channel ="6335145439";
    google_color_border = "ffffff";
    google_color_bg = "FFFFFF";
    google_color_link = "080878";
    google_color_url = "008000";
    google_color_text = "000000";
    //--></script>
    <script type="text/javascript"
    </script>
    <p />&nbsp;
    </div>



    </script><p />&nbsp;
    </body>
    </html>
    </div>
    </body>
    </html></div>
    </body>
    </html></div>
    </body>
    </html>
    CarbonTerry
    Semper Fi
    Still green...still mean......just not as lean

    Red Hawk Archery
    Zone 5 Photo
    My USMC

  5. #5
    judavvforum is offline Major
    Join Date
    Nov 2007
    Location
    Arizona
    Posts
    389

    Default Re: how to add a simple calculation

    Terry
    I just installed your calculator script and found that the "8" digit didn't work. I found that in your script above, the "8" digit is missing. This line of code should be: <input type="button" value=" 8 " class="btnBlue" onClick="num(">
    EDIT: The numeral eight & ), still won't show on this post, but works in the corrected coding on my site!
    Last edited by judavvforum; 05-06-2008 at 04:30 AM. Reason: correcting script

  6. #6
    Join Date
    Feb 2006
    Location
    Earth
    Posts
    8,721

    Default Re: how to add a simple calculation

    Hi, slightly simpler one here if any good.

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <form name="calculator">
    <!-- form the display to match the keypad -->
    <table border="1" cellpadding="1" bordercolor="#FFFFFF" bgcolor="#ababab" cellspacing="1" width="200">
    <tr>
    <td>
    <input type="text" size="25" length="25" value="" name="ans" style="background:beige;color:black;">
    </td>
    </tr>
    </table>
    <!-- form the keypad with buttons in a table -->
    <table border="1" cellpadding="1" bordercolor="#FFFFFF" cellspacing="1" width="200" bgcolor="#ababab">
    <tr>
    <td align="center">
    <input type="button" value=" 7 " name="seven" onClick="document.calculator.ans.value+='7'">
    </td>
    <td align="center">
    <input type="button" value=" 8 " name="eight" onClick="document.calculator.ans.value+='8'">
    </td>
    <td align="center">
    <input type="button" value=" 9 " name="nine" onClick="document.calculator.ans.value+='9'">
    </td>
    <td align="center">
    <input type="button" value=" / " name="divide" onClick="document.calculator.ans.value+='/'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" 4 " name="four" onClick="document.calculator.ans.value+='4'">
    </td>
    <td align="center">
    <input type="button" value=" 5 " name="five" onClick="document.calculator.ans.value+='5'">
    </td>
    <td align="center">
    <input type="button" value=" 6 " name="six" onClick="document.calculator.ans.value+='6'">
    </td>
    <td align="center">
    <input type="button" value=" * " name="multiply" onClick="document.calculator.ans.value+='*'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" 1 " name="one" onClick="document.calculator.ans.value+='1'">
    </td>
    <td align="center">
    <input type="button" value=" 2 " name="two" onClick="document.calculator.ans.value+='2'">
    </td>
    <td align="center">
    <input type="button" value=" 3 " name="three" onClick="document.calculator.ans.value+='3'">
    </td>
    <td align="center">
    <input type="button" value=" - " name="subtract" onClick="document.calculator.ans.value+='-'">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="button" value=" C " name="clear" onClick="document.calculator.ans.value=''">
    </td>
    <td align="center">
    <input type="button" value=" 0 " name="zero" onClick="document.calculator.ans.value+='0'">
    </td>
    <td align="center">
    <input type="button" value=" = " name="equal"
    onClick="document.calculator.ans.value=eval(docume nt.calculator.ans.value)">
    </td>
    <td align="center">
    <input type="button" value=" + " name="add" onClick="document.calculator.ans.value+='+'">
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

  7. #7
    judavvforum is offline Major
    Join Date
    Nov 2007
    Location
    Arizona
    Posts
    389

    Default Re: how to add a simple calculation

    Thanks Chris..
    Just tried it out and there is a small error:
    onClick="document.calculator.ans.value=
    eval(docume nt.calculator.ans.value)"> (Had to split this code so it didn't do a line break right where the error is!! Notice the space in the word document)

  8. #8
    CarbonTerry's Avatar
    CarbonTerry is offline Major General
    Join Date
    Oct 2005
    Location
    St L MO
    Posts
    2,590

    Default Re: how to add a simple calculation

    I don't know where that " symbol " came from in the 8 line.
    It's not in the original code.
    CarbonTerry
    Semper Fi
    Still green...still mean......just not as lean

    Red Hawk Archery
    Zone 5 Photo
    My USMC

  9. #9
    Join Date
    Feb 2006
    Location
    Earth
    Posts
    8,721

    Default Re: how to add a simple calculation

    Ah! well done. think it may of been me pasting it into the quote box as well that didnt help.

    Good luck.

  10. #10
    CarbonTerry's Avatar
    CarbonTerry is offline Major General
    Join Date
    Oct 2005
    Location
    St L MO
    Posts
    2,590

    Default Re: how to add a simple calculation

    Chris,
    The submitted code for the simple calculator would not total for me ??
    The strange symbol for my code was indeed in my original posting but not in the original code from my files.
    CarbonTerry
    Semper Fi
    Still green...still mean......just not as lean

    Red Hawk Archery
    Zone 5 Photo
    My USMC

  11. #11
    judavvforum is offline Major
    Join Date
    Nov 2007
    Location
    Arizona
    Posts
    389

    Default Re: how to add a simple calculation

    All's well and good fellows. The errors are easily changed and do work! Just wanted to make it known to everyone that might use them.

  12. #12
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: how to add a simple calculation

    I understand the need for a calculator where it is in fact needed. But for a simple addition ?

    Usualy these functions are part of order forms, or similar, where simplicity and functionality are a MUST, so a simple real time javascript would be much better.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49