Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2003
    Location
    New York
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Memory Storage Function of a Calculator

    Im trying to make a memory storage button on my calculator to work. I need tohave what ever is inside the text box to go into memory. then be able to recall it whenever i need it. Then when i no longer need the that particular number dump memory back to zero. I have most of everything typed up please take a look at it for me and post how you would go about making something. And if you have the extra time explain to me why you would do that. Thanks and I appreciate any and all suggestions.
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide from Incompatible Browsers
    var inputString = " " ;
    function updateString(value) {
    inputString += value;
    document.Calculator.Input.value = inputString;
    }
    // Stop Hiding Incompatible Browsers -->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide from Incompatible Browsers
    var memoryString = " ";
    function
    // Stop Hiding from Incompatible Browsers -->
    </SCRIPT>
    </HEAD>
    <BODY bgcolor="maroon">
    <DIV ALIGN="center">
    <FORM NAME="Calculator">
    <INPUT TYPE="text" NAME="Input" SIZE="22">
    <BR>
    <INPUT TYPE="button" NAME="plus" VALUE=" + " onClick="updateString(' + ')">
    <INPUT TYPE="button" NAME="minus" VALUE=" - " onClick="updateString(' - ')">
    <INPUT TYPE="button" NAME="times" VALUE=" x " onClick="updateString(' * ')">
    <INPUT TYPE="button" NAME="div" VALUE=" / " onClick="updateString(' / ')">
    <INPUT TYPE="button" NAME="mod" VALUE=" MOD " onClick="updateString(' % ')">
    <BR>
    <INPUT TYPE="button" NAME="nine" VALUE=" 9 " onClick="updateString(' 9 ')">
    <INPUT TYPE="button" NAME="eight" VALUE=" 8 " onClick="updateString(' 8 ')">
    <INPUT TYPE="button" NAME="seven" VALUE=" 7 " onClick="updateString(' 7 ')">
    <BR>
    <INPUT TYPE="button" NAME="six" VALUE=" 6 " onClick="updateString(' 6 ')">
    <INPUT TYPE="button" NAME="five" VALUE=" 5 " onClick="updateString(' 5 ')">
    <INPUT TYPE="button" NAME="four" VALUE=" 4 " onClick="updateString(' 4 ')">
    <BR>
    <INPUT TYPE="button" NAME="three" VALUE=" 3 " onClick="updateString(' 3 ')">
    <INPUT TYPE="button" NAME="two" VALUE=" 2 " onClick="updateString(' 2 ')">
    <INPUT TYPE="button" NAME="one" VALUE=" 1 " onClick="updateString(' 1 ')">
    <BR>
    <INPUT TYPE="button" NAME="zero" VALUE=" 0 " onClick="updateString(' 0 ')">
    <BR>
    <INPUT TYPE="button" NAME="point" VALUE=" . " onClick="updateString('.')">
    <INPUT TYPE="button" NAME="clear" VALUE=" Clear " onClick="Input.value=' '; inputString=''">
    <INPUT TYPE="button" NAME="Calc" VALUE=" = " onClick="Input.value=eval(inputString); inputString=' ' ">
    <BR>
    <INPUT TYPE="button" NAME="MemoryStore" VALUE=" M " onClick=" ">
    <INPUT TYPE="button" NAME="MemoryRecall" VALUE=" MRC " onClick=" ">
    <INPUT TYPE="button" NAME="MemoryClear" VALUE=" MC " onClick=" ">
    </FORM>
    </DIV>
    </BODY>
    </HTML>



    P.s.
    I have no clue, somewheres in this stuff im having a problem with some of the buttons dont work properly. If u see exactly what it is please call it out to me. I have been looking at it this code for quite some time.

    Thanks Again.

  • #2
    New Coder
    Join Date
    Oct 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I would recommend placing a hidden field in that form which will do the following...
    MemoryStore: Set the hidden field to the specified value (overwrites previous)
    MemoryRecall: Get the value of the hidden field
    MemoryClear: Set the hidden field's value to nothing

    - PowerPro

  • #3
    New Coder
    Join Date
    May 2003
    Location
    New York
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But how would I go about setting up a hidden field, most of this code a took from a text book, Its a project Im doing for my JavaScript class. I am in the process of learning what all this is, but most of the students in the class seem to be more advanced in this area than myself. The professor wanted us to find a solution for making anything in the text box in the form remain in memory, the idea of memoryString was given to me by another student but was unable to explain to me what i had to do and the process of going about it. Again I appreciate any and all info, thank you for ur reply, but im still not understanding what to do sorry.

  • #4
    New Coder
    Join Date
    Oct 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    JavaScript class? If it is a class, should you not be learning it on your own?

    A hidden form field is just like any other form field except you set the TYPE tag to hidden, and then the user cannot see it. I gave you assistance, I will not provide you code, sorry.


    - PowerPro


  •  

    Posting Permissions

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