#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Help...calculator memory function on M+,M-,MR..


    hi all....
    anyone knows how to code the function of MR,M+,M- in calculatorusing javascript?? .i did some code and no one works,,,
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,142
    Rep Power
    9398
    I can't imagine needing anything more complicated than M+ adding the value to a variable, M- subtracting the value from the same variable, and MR displaying the current value of the variable. I also can't imagine that being difficult or complicated to implement, but I can't see your code so...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by cloudzell91
    hi all....
    anyone knows how to code the function of MR,M+,M- in calculatorusing javascript?? .i did some code and no one works,,,
    heres the code

    <html>
    <head>
    <title></title>
    <script>
    var x;
    var memory = 0;
    function cal(z)
    {
    x=eval(z.Input.value);
    z.Input.value=x;
    }
    function boom(z)
    {
    z.Input.value=" ";
    }

    function memoryrecall(z)
    {

    var memory = ;
    if (memory==0 ||{memory = ""}

    }

    function memorysub(z)
    {

    }






    </script>
    </head>
    <body>
    <form name="z">
    <h3>Grade Calculator</h3>
    <br/>
    <hr width=500 align="left">

    <INPUT TYPE="text" NAME="Input" Size="23">
    <br/>
    <INPUT TYPE="button" NAME="seven" VALUE="7" OnClick="z.Input.value += '7'" style="width: 40px; height: 40px" >

    <INPUT TYPE="button" NAME="eight" VALUE="8" OnCLick="z.Input.value += '8'" style="width: 40px; height: 40px" >

    <INPUT TYPE="button" NAME="nine" VALUE="9" OnClick="z.Input.value += '9'" style="width: 40px; height: 40px" >

    <INPUT TYPE="button" NAME="plus" VALUE="+" OnClick="z.Input.value += ' + '"style="width: 40px; height: 40px" >
    <br/>
    <INPUT TYPE="button" NAME="four" VALUE="4" OnClick="z.Input.value += ' 4 '" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="five" VALUE="5" OnClick="z.Input.value += '5'" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="six" VALUE="6" OnCLick="z.Input.value += '6'" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="times" VALUE="-" OnClick="z.Input.value += ' - '" style="width: 40px; height: 40px">
    <br/>
    <INPUT TYPE="button" NAME="one" VALUE="1" OnClick="z.Input.value += '1'" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="two" VALUE="2" OnClick="z.Input.value += '2'" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="three" VALUE="3" OnClick="z.Input.value += '3'" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="times" VALUE="*" OnClick="z.Input.value += ' * '" style="width: 40px; height: 40px">
    <br/>


    <INPUT TYPE="button" NAME="zero" VALUE="0" OnClick="z.Input.value += '0'" style="width: 40px; height: 40px">
    <INPUT TYPE="button" NAME="point" VALUE="." OnClick="z.Input.value += '.'" style="width: 40px; height: 40px">
    <INPUT TYPE="button" NAME="equal" value="= " OnClick="cal(this.form)" style="width: 40px; height: 40px">


    <INPUT TYPE="button" NAME="Divide" value="/" OnClick="z.Input.value += '/'" style="width: 40px; height: 40px">
    <br/>



    <INPUT TYPE="button" NAME="clear" VALUE="C" OnClick="boom(this.form)" style="width: 40px; height: 40px">


    <INPUT TYPE="button" NAME="point" VALUE="MR" OnClick="memoryrecall(this.form)" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="memorysub" VALUE="M-" OnClick="memorysub(this.form)" style="width: 40px; height: 40px">

    <INPUT TYPE="button" NAME="memoryadd" VALUE="M+"OnClick="memoryadd(this.form)" style="width: 40px; height: 40px">








    <hr width=500 align="left">
    <h6>Copyright&copy; 2013<br/>
    </h3>


    </form>
    </body>

    </html>


    ,,,,,,,,,,,,,,,,,,,,,
    ,,,,,,,,,,,,,,,,,,,,,
    really dnt know mr,m+m-........
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,142
    Rep Power
    9398
    Syntax error aside, when you did the "var memory" inside the memoryrecall() function you lost access to the memory you defined outside it. Get rid of that statement and continue onwards.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0
    <script>
    var x;
    var memory = 0;

    function cal(z)
    {
    x=eval(z.Input.value);
    z.Input.value=x;
    }
    function boom(z)
    {
    z.Input.value=" ";
    }


    function memoryrecall(z)
    {
    z.form.input.value = memory;


    }

    function memorysub(z)
    {

    memory = parseInt (el.form.input.value) - parseInt (memory);

    }
    function memoryadd(z)
    {

    memory = parseInt (z.form.input.value) + parseInt (memory);

    }



    </script>
    ,,,,
    ,,,,
    still dont work,,,,

    ,,btw thanks 4 the help requinix
  10. #6
  11. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    Please be more specific then just "don't work".
    What does "not work"?
    How have you tested it?
    Any syntax or logic error?
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by MrFujin
    Please be more specific then just "don't work".
    What does "not work"?
    How have you tested it?
    Any syntax or logic error?
    What does "not work"? the memory or the MR M- and M+..that all.


    How have you tested it? Any syntax or logic error? ..i tried no functions at all,,,any errors? am just using notepad cant identify or hardly to identify...the error,,,,, that why i need help lolz
    ...sorry am not a programming wiz,,am learning on it lol,

IMN logo majestic logo threadwatch logo seochat tools logo