Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Member #
    25837
    Hello Everyone,

    The following html code supposed to do simple arithmetic operations (calculator). It generates the calculator table but i can't do any computation. I don't know the problem. Please see the code and give me suggestion/s.

    Thank you,

    joealem
    P.S: I am using dreamweaver.


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <head>
    <title> CALCULATOR </title>
    <style type="text/css">
    td{ 
    border:1px solid blue;
    width: 50px;
    font-style:inherit
    font-size:24px
    }
    
    #results {
    height:20px;
    }
    </style>
    </head>
    <body>
    
    <table width="379" height="229" border="10" cellpadding="2" cellspacing="2" bordercolor="#FF00CC" bordercolorlight="#99CC66" bgcolor="#FFFF33">
    
    <tr>
    <td colspan="4" id="results"></td>
    </tr>
    
    <tr>
    <td width="88"><a href="#"onclick="return addDigit(1)">1</a></td>
    <td width="91" bordercolor="#00CC00"><a href="#"onclick="return addDigit(2)">2</a></td>
    <td width="85"><a href="#"onclick="return addDigit(3)">3</a></td>
    <td width="89"><a href="#"onclick="return addDigit('+')">+</a></td>
    </tr>
    <tr>
    <td><a href="#"onclick="return addDigit(4)">4</a></td>
    <td><a href="#"onclick="return addDigit(5)">5</a></td>
    <td><a href="#"onclick="return addDigit(6)">6</a></td>
    <td><a href="#"onclick="return addDigit('-')">-</a></td>
    </tr>
    <tr>
    <td><a href="#"onclick="return addDigit(7)">7</a></td>
    <td><a href="#"onclick="return addDigit(8)">8</a></td>
    <td><a href="#"onclick="return addDigit(9)">9</a></td>
    <td><a href="#"onclick="return addDigit('*')">x</a></td>
    </tr>
    <tr>
    <td><a href="#"onclick="return reset1()">Clear</a></td>
    <td><a href="#"onclick="return addDigit(0)">0</a></td>
    <td><a href="#"onclick="return calculate()">=</a></td>
    <td><a href="#"onclick="return addDigit('/')">/</a></td>
    </tr>
    </table>
    <script type="text/javescript">
    function addDigit(digit){
    var resultField=document.getElementById("results");
    resultField.innerHTML=resultField.innerHTML+digit;
    return false;
    }
    function calculate(){
    var resultField=document.getElementById("results");
    resultField.innerHTML=eval(resultField.innerHTML);
    return false;
    }
    function reset1(){
    var resultField=document.getElementById("results");
    resultField.innerHTML="";
    return false;
    }
    </script>
    </body>
    </html>

  2.  

  3. #2
    Junior Member
    Join Date
    Nov 2010
    Posts
    23
    Member #
    24956
    line 53 change from

    Code:
    <script type="text/javescript">
    to

    Code:
    <script type="text/javascript">
    you simply misspelled "javascript"

  4. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Member #
    25837
    God. I spent a lot of time to figure out the problem. Thank You so much for the help!!! I got it!!!


    Quote Originally Posted by EvilivE View Post
    line 53 change from

    Code:
    <script type="text/javescript">
    to

    Code:
    <script type="text/javascript">
    you simply misspelled "javascript"

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Welcome to web design, JoeAlem. I once spent 8 hours trying to find an error in code that turned out to be two transposed letters.

    Just make sure you learn from it. Then all your frustration and throwing stuff off the wall becomes worthwhile. Especially if you do something cool like break a keyboard by punching it like that hyperactive German kid on Youtube.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:07 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com