1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

need a little codeing help

Discussion in 'Software Development' started by charlzguitarz, Jun 8, 2019.

Advertisement
  1. charlzguitarz

    charlzguitarz Thread Starter

    Joined:
    Dec 21, 2018
    Messages:
    28
    Hi, Just wading thru trying to keep my little mind intact. My project is a
    calculator. The code:
    refreshes database, doesn't display data being entered, but does create the

    records (zeroes), prints record.
    Im hoping someone will take a look at this, please.
    Below is my code; Yeah, I could have removed a little:
    <!DOCTYPE html><html><head>
    <meta charset=utf-8>
    <title>personal calculator</title>

    <style type="text/css">input { text-align:center; } </style>

    <!-- refreshes database, doesn't display data being entered, does create

    record(zeroes), prints record -->

    </head>
    <BODY><p><center>
    <marquee behavior="scroll" direction="left" scrollamount="5" id="marquee2">
    <img src="http://localhost/images/refreshnow.gif" height=50 width=100>
    <img src="http://localhost/images/becertain.gif" height=50 width=100>
    </marquee><br />
    <marquee behavior="scroll" direction="right" scrollamount="10" id="marquee2">
    <img src="http://localhost/images/refreshnow.gif" height==50 width=100>
    <img src="http://localhost/images/becertain.gif" height==50

    width=100></marquee><br />
    <img src="http://localhost/images/back.gif">

    <!--****************************************************************** -->
    <a href="http://localhost/calculator/clear1.php">
    <img src="http://localhost/images/yesbutton.png" height=25 width=50 alt="yes

    button"></a>
    <!--****************************************************************** -->

    click
    <img src="http://localhost/images/nobutton.png" height=25 width=50 alt="no

    button"></a>
    <img src="http://localhost/images/digitdown.gif"><br>

    <!--VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV -->
    <style type="text/css">
    body {font-family: helvetica}
    p {font-size: 12pt}
    .red {color: red}
    .blue {color: blue}
    </style>

    <SCRIPT>
    var Memory = 0;
    var purpose = "";
    var value1 = 0;
    var value2 = 0;
    var NewNumber = "";
    var opvalue = "";
    var op = opvalue;

    function Display(displaynumber) {
    document.calculator.answer.value = displaynumber;
    }

    function MemoryClear()
    {Memory = 0;document.calculator.mem.value = "";}

    function MemoryRecall(answer)
    {
    if(NewNumber !== "")
    {value2 += answer;}
    else
    {value1 = answer;}
    NewNumber = "";
    Display(answer);
    }

    function MemorySubtract(answer)
    {Memory = Memory - eval(answer);}

    function MemoryAdd(answer)
    {Memory = Memory + eval(answer);
    document.calculator.mem.value = " M ";NewNumber = "";}

    function ClearCalc()
    {value1 = "";value2 = "";NewNumber = "";Display("");}

    function Backspace(answer)
    {
    answerlength = answer.length;
    answer = answer.substring(0, answerlength - 1);if (value2 !== "")
    {value2 = answer.toString();Display(value2);}
    else
    {value1 = answer.toString();Display(value1);}
    }

    function CECalc()
    {value2 = "";NewNumber = "yes";Display("");}
    function CheckNumber(answer)
    {
    if(answer == ".")
    {
    Number = document.calculator.answer.value;
    if(Number.indexOf(".") != -1)
    {answer = ""; }
    }
    if(NewNumber == "yes")
    {value2 += answer;Display(value2);}
    else
    {
    if(NewNumber '==' "")
    {value1 = answer;value2 = "";NewNumber = "no";}
    else
    {value1 += answer;}
    Display(value1);
    }
    }
    function AddButton(x)
    {
    if(x == 1) EqualButton();
    if(value2 !== "")
    {value1 = parseFloat(value1) + parseFloat(value2);}
    NewNumber = "yes";
    opvalue = '+';
    Display(value1);
    }
    function SubButton(x)
    {
    if(x == 1) EqualButton();
    if(value2 !== "")
    {value1 = parseFloat(value1) - parseFloat(value2);}
    NewNumber = "yes";
    opvalue = '-';
    Display(value1);
    }
    function MultButton(x)
    {
    if(x == 1) EqualButton();
    if(value2 !== "")
    {value1 = parseFloat(value1) * parseFloat(value2);}
    NewNumber = "yes";
    opvalue = '*';
    Display(value1);
    }
    function DivButton(x)
    {
    if(x == 1) EqualButton();
    if(value2 !== "")
    {value1 = parseFloat(value1) / parseFloat(value2);}
    NewNumber = "yes";
    opvalue = '/';
    Display(value1);
    }
    function SqrtButton()
    {value1 = Math.sqrt(value1);NewNumber = "";Display(value1);}
    function PercentButton()
    {
    if(NewNumber != "blank")
    {value2 *= '.01';NewNumber = "";Display(value2);}
    }
    function RecipButton()
    {value1 = 1/value1;NewNumber = "";Display(value1);}
    function NegateButton()
    {value1 = parseFloat(-value1);NewNumber = "no";Display(value1);
    }
    function EqualButton() {
    if(opvalue == '+') AddButton(0);
    if(opvalue == '-') SubButton(0);
    if(opvalue == '*') MultButton(0);
    if(opvalue == '/') DivButton(0);
    value2 = "";
    opvalue = "";
    }
    function OnCalc(purpose,value1,op,value2,total)
    {return(purpose,value1,op,value2,total);}
    // End -->
    </script>
    </head>
    <body>
    <center>
    <!-- ------------------------------------------------------------------- -->
    <FORM name="calculator" id="calculator"
    action="http://localhost/calculator/post1.php" method="post">
    <input type="text" id="purpose" name="purpose" size="46" value="what's this

    for?" onFocus="this.value=''">
    <!-- ------------------------------------------------------------------- -->

    <table bgcolor="#aaaaaa" width=220>
    <tr><td>
    <table bgcolor="#cccccc" border=1>
    <tr><td>
    <table border=0 cellpadding=0>
    <tr><td bgcolor="#000080"><b style="color:white">Calculator</b></td></tr>
    <tr><td>
    <table width="100%" border=0>
    <tr><td colspan=6><input type="text" name="answer" size=30 maxlength=30

    onChange="CheckNumber(this.value)"></td></tr>
    <tr><td colspan=6>
    <table border=0 cellpadding=0>
    <tr><td>
    <input type="text" name="mem" size=3 maxlength=3> <input type="button"

    name="backspace" class="red" value="Backspace"

    onClick="Backspace(document.calculator.answer.value); return false;"> <input

    type="button" name="CE" class="red"

    value=" CE " onClick="CECalc(); return false;"> <input type="reset" name="C"

    class="red" value=" C "

    onClick="ClearCalc(); return false;">
    </td></tr>
    </table>
    </td></tr>
    <tr><td><input type="button" name="MC" class="red" value=" MC "

    onClick="MemoryClear(); return false;"></td>
    <td><input type="button" name="calc7" class="blue" value=" 7 "

    onClick="CheckNumber('7'); return false;"></td>
    <td><input type="button" name="calc8" class="blue" value=" 8 "

    onClick="CheckNumber('8'); return false;"></td>
    <td><input type="button" name="calc9" class="blue" value=" 9 "

    onClick="CheckNumber('9'); return false;"></td>
    <td><input type="button" name="divide" class="red" value=" / "

    onClick="DivButton(1); return false;"></td>
    <td><input type="button" name="sqrt" class="blue" value="sqrt"

    onClick="SqrtButton(); return false;"></td></tr>
    <tr>
    <td><input type="button" name="MR" class="red" value=" MR "

    onClick="MemoryRecall(Memory); return false;"></td>
    <td><input type="button" name="calc4" class="blue" value=" 4 "

    onClick="CheckNumber('4'); return false;"></td>
    <td><input type="button" name="calc5" class="blue" value=" 5 "

    onClick="CheckNumber('5'); return false;"></td>
    <td><input type="button" name="calc6" class="blue" value=" 6 "

    onClick="CheckNumber('6'); return false;"></td>
    <td><input type="button" name="multiply" class="red" value=" * "

    onClick="MultButton(1); return false;"></td>
    <td><input type="button" name="percent" class="blue" value=" % "

    onClick="PercentButton(); return false;"></td></tr>
    <tr><td><input type="button" name="MS" class="red" value=" MS "

    onClick="MemorySubtract

    (document.calculator.answer.value); return false;"></td>
    <td><input type="button" name="calc1" class="blue" value=" 1 "

    onClick="CheckNumber('1'); return false;"></td>
    <td><input type="button" name="calc2" class="blue" value=" 2 "

    onClick="CheckNumber('2'); return false;"></td>
    <td><input type="button" name="calc3" class="blue" value=" 3 "

    onClick="CheckNumber('3'); return false;"></td>
    <td><input type="button" name="minus" class="red" value=" - "

    onClick="SubButton(1); return false;"></td>
    <td><input type="button" name="recip" class="blue" value="1/x "

    onClick="RecipButton(); return false;"></td></tr>
    <tr><td><input type="button" name="Mplus" class="red" value=" M+ "

    onClick="MemoryAdd

    (document.calculator.answer.value); return false;"></td>
    <td><input type="button" name="calc0" class="blue" value=" 0 "

    onClick="CheckNumber('0'); return false;"></td>
    <td><input type="button" name="negate" class="blue" value="+/- "

    onClick="NegateButton(); return false;"></td>
    <td><input type="button" name="dot" class="blue" value=" . "

    onClick="CheckNumber('.'); return false;"></td>
    <td><input type="button" name="plus" class="red" value=" + "

    onClick="AddButton(1); return false;"></td>
    <td><input type="button" name="equal" class="red" value=" = "

    onClick="EqualButton(); return false;"></td>
    </tr>
    </table>
    </td></tr>
    </table>
    </td></tr>
    </table>
    </td></tr>
    </table>
    <br>
    <input type="submit" id="keypad" name="keypad" value="submit">
    </form>
    <a href="http://localhost/calculator/print1.php">print</a><br>
    </center></body></html>

    Thanks
     
  2. lunarlander

    lunarlander

    Joined:
    Sep 21, 2007
    Messages:
    10,847
    So the problem you want to solve are 1) it doesn't display and 2) it records 0's in the database ? Please clarify.
     
  3. charlzguitarz

    charlzguitarz Thread Starter

    Joined:
    Dec 21, 2018
    Messages:
    28
  4. charlzguitarz

    charlzguitarz Thread Starter

    Joined:
    Dec 21, 2018
    Messages:
    28
    I'm sending a couple of screenshots: i showing that refreshes the database
    1 in the midst of entering data and nothing showing the data entered,
    1 showing that data is being inserted into the database
    and 1 showing the data that has been entered.
     

    Attached Files:

  5. charlzguitarz

    charlzguitarz Thread Starter

    Joined:
    Dec 21, 2018
    Messages:
    28
    I was hoping someone would be interested in helping. Sorry 'bout the images. maybe some advice there? thanks.
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...

Short URL to this thread: https://techguy.org/1228324

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice