Blogger Calculator
1. Sign in to your blog, then in "DASHBOARD" go to "LAYOUT".
2. Then go to "TEMPLATE", "PAGE ELEMENT".
3. Then "Add Page Element", HTML/JavaScript.
4. Just copy and paste the below code. Then "SAVE CHANGES".
5. You are Done. (Use at your own risk)
<style type="text/css"> body {font-family: helvetica} p {font-size: 10pt} .red {color: red} .blue {color: blue} </style>
<script language="JavaScript"> var Memory = 0; var Number1 = ""; var Number2 = ""; var NewNumber = "blank"; var opvalue = "";
function Display(displaynumber) { document.calculator.answer.value = displaynumber; }
function MemoryClear() { Memory = 0; document.calculator.mem.value = ""; }
function MemoryRecall(answer) { if(NewNumber != "blank") { Number2 += answer; } else { Number1 = answer; } NewNumber = "blank"; Display(answer); }
function MemorySubtract(answer) { Memory = Memory - eval(answer); }
function MemoryAdd(answer) { Memory = Memory + eval(answer); document.calculator.mem.value = " M "; NewNumber = "blank"; }
function ClearCalc() { Number1 = ""; Number2 = ""; NewNumber = "blank"; Display(""); }
function Backspace(answer) { answerlength = answer.length; answer = answer.substring(0, answerlength - 1); if (Number2 != "") { Number2 = answer.toString(); Display(Number2); } else { Number1 = answer.toString(); Display(Number1); } }
function CECalc() { Number2 = ""; NewNumber = "yes"; Display(""); }
function CheckNumber(answer) { if(answer == ".") { Number = document.calculator.answer.value; if(Number.indexOf(".") != -1) { answer = ""; } } if(NewNumber == "yes") { Number2 += answer; Display(Number2); } else { if(NewNumber == "blank") { Number1 = answer; Number2 = ""; NewNumber = "no"; } else { Number1 += answer; } Display(Number1); } }
function AddButton(x) { if(x == 1) EqualButton(); if(Number2 != "") { Number1 = parseFloat(Number1) + parseFloat(Number2); } NewNumber = "yes"; opvalue = '+'; Display(Number1); }
function SubButton(x) { if(x == 1) EqualButton(); if(Number2 != "") { Number1 = parseFloat(Number1) - parseFloat(Number2); } NewNumber = "yes"; opvalue = '-'; Display(Number1); }
function MultButton(x) { if(x == 1) EqualButton(); if(Number2 != "") { Number1 = parseFloat(Number1) * parseFloat(Number2); } NewNumber = "yes"; opvalue = '*'; Display(Number1); }
function DivButton(x) { if(x == 1) EqualButton(); if(Number2 != "") { Number1 = parseFloat(Number1) / parseFloat(Number2); } NewNumber = "yes"; opvalue = '/'; Display(Number1); }
function SqrtButton() { Number1 = Math.sqrt(Number1); NewNumber = "blank"; Display(Number1); }
function PercentButton() { if(NewNumber != "blank") { Number2 *= .01; NewNumber = "blank"; Display(Number2); } }
function RecipButton() { Number1 = 1/Number1; NewNumber = "blank"; Display(Number1); }
function NegateButton() { Number1 = parseFloat(-Number1); NewNumber = "no"; Display(Number1); }
function EqualButton() { if(opvalue == '+') AddButton(0); if(opvalue == '-') SubButton(0); if(opvalue == '*') MultButton(0); if(opvalue == '/') DivButton(0); Number2 = ""; opvalue = ""; } // End --> </script>
<form name="calculator"> <table width="220" bgcolor="Silver"> <tr><td> <table border="1" bgcolor="Silver"> <tr><td> <table border="0" cellpadding="0"> <tr><td><b><marquee width="100%" loop="-1" scrollamount="4" bgcolor=""><font face="Arial" color="white"> A Day Without Blogging Is Like A Day Without Sunshine...</font></marquee></b></td></tr> <tr><td> <table border="0" width="100%"> <tr><td colspan="5"><input maxlength="33" onchange="CheckNumber(this.value)" name="answer" size="33" type="text"/></td></tr> <tr><td colspan="5"> <table border="0" cellpadding="0"> <tr><td> <input maxlength="3" name="mem" size="3" type="text"/> <input class="red" value="Backspace" name="backspace" onclick="Backspace(document.calculator.answer.value); return false;" type="button"/> <input class="red" value="CE" name="CE" onclick="CECalc(); return false;" type="button"/> <input class="red" value="C " name="C" onclick="ClearCalc(); return false;" type="reset"/> </td></tr> </table> </td></tr> <tr><td><input class="red" value=" M " name="MC" onclick="MemoryClear(); return false;" type="button"/></td> <td><input class="blue" value=" 7 " name="calc7" onclick="CheckNumber('7'); return false;" type="button"/></td> <td><input class="blue" value=" 8 " name="calc8" onclick="CheckNumber('8'); return false;" type="button"/></td> <td><input class="blue" value=" 9 " name="calc9" onclick="CheckNumber('9'); return false;" type="button"/></td> <td><input class="red" value=" / " name="divide" onclick="DivButton(1); return false;" type="button"/></td></tr> <tr><td><input class="red" value=" MR " name="MR" onclick="MemoryRecall(Memory); return false;" type="button"/></td> <td><input class="blue" value=" 4 " name="calc4" onclick="CheckNumber('4'); return false;" type="button"/></td> <td><input class="blue" value=" 5 " name="calc5" onclick="CheckNumber('5'); return false;" type="button"/></td> <td><input class="blue" value=" 6 " name="calc6" onclick="CheckNumber('6'); return false;" type="button"/></td> <td><input class="red" value=" * " name="multiply" onclick="MultButton(1); return false;" type="button"/></td></tr> <tr><td> <input class="red" value=" MS " name="MS" onclick="MemorySubtract(document.calculator.answer.value); return false;" type="button"/> </td> <td><input class="blue" value=" 1 " name="calc1" onclick="CheckNumber('1'); return false;" type="button"/></td> <td><input class="blue" value=" 2 " name="calc2" onclick="CheckNumber('2'); return false;" type="button"/></td> <td><input class="blue" value=" 3 " name="calc3" onclick="CheckNumber('3'); return false;" type="button"/></td> <td><input class="red" value=" - " name="minus" onclick="SubButton(1); return false;" type="button"/></td></tr> <tr><td> <input class="red" value=" M+ " name="Mplus" onclick="MemoryAdd(document.calculator.answer.value); return false;" type="button"/> </td> <td><input class="blue" value=" 0 " name="calc0" onclick="CheckNumber('0'); return false;" type="button"/></td> <td><input class="blue" value=" +/-" name="negate" onclick="NegateButton(); return false;" type="button"/></td> <td><input class="blue" value=" . " name="dot" onclick="CheckNumber('.'); return false;" type="button"/></td> <td><input class="red" value=" + " name="plus" onclick="AddButton(1); return false;" type="button"/></td></tr> <tr><td><a href="http://www.inform-me-now.blogspot.com"><input name="button" type="button" value="AtoZ"/></a></td> <td><input class="blue" value="sqrt" name="sqrt" onclick="SqrtButton(); return false;" type="button"/></td> <td><input class="blue" value=" % " name="percent" onclick="PercentButton(); return false;" type="button"/></td> <td><input class="blue" value="1/x" name="recip" onclick="RecipButton(); return false;" type="button"/></td> <td><input class="red" value=" = " name="equal" onclick="EqualButton(); return false;" type="button"/></td></tr> </table> </td></tr> </table> </td></tr> </table> </td></tr> </table> </form>
|
0 comments:
Post a Comment