Calculator Needed for Website Homepage

Discussion in 'Programming' started by escortseo, Feb 8, 2010.

  1. #1
    Please see homepage of http://www.healthteamllc.com/ -- we're looking for a programmer to take an algorhythm and program this calculator so it works in all browsers. Functionality we're looking for includes:

    * Dynamic updating -- no need for a "submit" button
    * Follow the design shown on Website
    * Generate a printable analysis that is sent only after user enters contact information (thus, there is the need for some database programming to store leads.)

    There are many other programming tasks we need done on this Website, and we're looking for a partner who we can send future work to as well.
     
    escortseo, Feb 8, 2010 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check this one.

    
    <html>
    <head>
    <title>Web Based Calculator</title>
    </head>
    <body>
    
    <script language="javascript">
    <!-- hide this script tag's contents from old browsers
    function addChar(input, character)
    {
    if(input.value == null || input.value == "0")
    input.value = character
    else
    input.value += character
    }
    function deleteChar(input)
    {
    input.value = input.value.substring(0, input.value.length - 1)
    }
    function changeSign(input)
    {
    // could use input.value = 0 - input.value, but let's show off substring
    if(input.value.substring(0, 1) == "-")
    input.value = input.value.substring(1, input.value.length)
    else
    input.value = "-" + input.value
    }
    function compute(form) 
    {
    form.display.value = eval(form.display.value)
    }
    function square(form) 
    {
    form.display.value = eval(form.display.value) * eval(form.display.value)
    }
    function checkNum(str) 
    {
    for (var i = 0; i < str.length; i++) {
    var ch = str.substring(i, i+1)
    if (ch < "0" || ch > "9") {
    if (ch != "/" && ch != "*" && ch != "+" && ch != "-" 
    && ch != "(" && ch!= ")") {
    alert("invalid entry!")
    return false
    }
    }
    }
    return true
    }
    <!-- done hiding from old browsers -->
    </script>
    <form>
    <div align="center"><center><table border="5" align="center"
    bordercolordark="#800000" bgcolor="#C0C0C0">
    <tr align="center">
    <td colspan="4"><table border="3" width="250">
    
    <tr>
    <td align="center" width="236"><input name="display" value="0" size="32"></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr align="center">
    <td><input type="button" value="    7    " onClick="addChar(this.form.display, '7')"> </td>
    <td><input type="button" value="    8    " onClick="addChar(this.form.display, '8')"> </td>
    <td><input type="button" value="    9    " onClick="addChar(this.form.display, '9')"> </td>
    <td><input type="button" value="    /     " onClick="addChar(this.form.display, '/')"> </td>
    </tr>
    <tr align="center">
    
    <td><input type="button" value="    4    " onClick="addChar(this.form.display, '4')"> </td>
    <td><input type="button" value="    5    " onClick="addChar(this.form.display, '5')"> </td>
    <td><input type="button" value="    6    " onClick="addChar(this.form.display, '6')"> </td>
    <td><input type="button" value="    *    " onClick="addChar(this.form.display, '*')"> </td>
    </tr>
    <tr align="center">
    <td><input type="button" value="    1    " onClick="addChar(this.form.display, '1')"> </td>
    <td><input type="button" value="    2    " onClick="addChar(this.form.display, '2')"> </td>
    <td><input type="button" value="    3    " onClick="addChar(this.form.display, '3')"> </td>
    <td><input type="button" value="     -    " onClick="addChar(this.form.display, '-')"> </td>
    
    </tr>
    <tr align="center">
    <td><input type="button" value="    0    " onClick="addChar(this.form.display, '0')"> </td>
    <td><input type="button" value="     .    " onClick="addChar(this.form.display, '.')"> </td>
    <td><input type="button" value="   +/-   " onClick="changeSign(this.form.display)"> </td>
    <td><input type="button" value="    +    " onClick="addChar(this.form.display, '+')"> </td>
    </tr>
    <tr align="center">
    <td><input type="button" value="    (    " onClick="addChar(this.form.display, '(')"> </td>
    <td><input type="button" value="     )    " onClick="addChar(this.form.display, ')')"> </td>
    <td><input type="button" value="   sq    "
    onClick="if (checkNum(this.form.display.value))
    { square(this.form) }"> </td>
    
    <td><input type="button" value="    &lt;-   " onClick="deleteChar(this.form.display)"> </td>
    </tr>
    <tr align="center">
    <td colspan="2"><input type="button" value="      Enter      " name="enter"
    onClick="if (checkNum(this.form.display.value))
    { compute(this.form) }"> </td>
    <td colspan="2"><input type="button" value="         C          "
    onClick="this.form.display.value = 0 "> </td>
    </tr>
    </table>
    </center></div>
    </form>
    
    </body>
    </html>
    
    
    PHP:
     
    NeoCambell, Feb 9, 2010 IP