The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Help...calculator memory function on M+,M-,MR..
Discuss Help...calculator memory function on M+,M-,MR.. in the JavaScript Development forum on Dev Shed. Help...calculator memory function on M+,M-,MR.. JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 13th, 2013, 06:59 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 5
Time spent in forums: 58 m 30 sec
Reputation 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,,,
|

January 13th, 2013, 07:11 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
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...
|

January 13th, 2013, 07:52 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 5
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
Quote: | 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© 2013<br/>
</h3>
</form>
</body>
</html>
,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,
really dnt know mr,m+m-........
|

January 13th, 2013, 08:09 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
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.
|

January 13th, 2013, 10:05 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 5
Time spent in forums: 58 m 30 sec
Reputation 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
|

January 13th, 2013, 12:32 PM
|
 |
Lord of the Dance
|
|
|
|
|
Please be more specific then just "don't work".
What does "not work"?
How have you tested it?
Any syntax or logic error?
|

January 13th, 2013, 01:40 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 5
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
Quote: | 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,
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|