Javascript Calculator Significant Figures
Dec 1, 2006
Basically, i'm in 11th grade and i just got an assignment where im supposed to display 5 prompts, have the user type in numbers, the numbers multiply, and then these numbers are to be displayed in signifcant figures.
The first part is cake. The numbers multiply and everything, and I discovered a function called [var].toPrecision() which gives me significant figures according to the number I ask manually.
Unfortunatly the assignment is much more technically than that. If for example i multiply 1.2222222 * 100 the signifcant figures should end at the lowest decimal, making the answer 122. And if i multiply 33.33 * 33.33 then the lowest decimal is to the hundreths place and the answer is 99.99.
View 1 Replies
ADVERTISEMENT
Mar 3, 2007
I am trying to write a currency calculator that can convert between 4 currencies.
I have managed to get as far as to convert from one currency to the other 3 but can not make it convert between the others. Could you please give me some advice how to continue? Code:
View 5 Replies
View Related
Oct 4, 2009
I am working on an Mpg calculator and I am stuck.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
I have a mistake when it is suppose to calculate.
View 4 Replies
View Related
Mar 25, 2011
I'm trying to make a calculator app; with a few differences. I have a text field with a numberpad below it, I got the numbers to show up in the text field, but am unsure as to how when I hit the enter button - it would store them in a variable?...I am also wondering as to how it would store current value and then allow me to input another value(maybe on the next page) and either subtract or add to it(the first value that is stored).I am also wondering how to get a decimal point in place(need it for currency).
Here is my code:
<html>
<head>
<script type = "text/javascript">
[code].....
View 10 Replies
View Related
Dec 2, 2011
I have the last assignment that she wants us to do and I had to pull up another assignment that she wanted us to build upon( which is one of those coding without anything advance)
<html>
<head>
<title>
[code]....
now she wants us to do max <beta and then name the variables with if a<b and I don't know if I put that in the concatenation or what to name my variables!
View 18 Replies
View Related
Jan 4, 2007
I am trying to create a price calculator that automatically calculates the price of custom made picture frame. I got an equation that finds the square area of the frame by multiplying the perimeter (2*length*width) by the thickness (which the user can choose from 1.5", 2" or 3"). Then it multiplies it by a decimal number (0.27 if the frame is 1.5" thick, 0.23 if its 2" thick, and 0.18 if its 3" thick). Then it adds a $5 custom made fee to the final answer. But when I save it to an html file and load it in Internet Explorer, it doesn't calculate. Code:
View 5 Replies
View Related
Jul 26, 2007
I'm having some problems with a calculator that I'm working on and am stumped on a particular situation regarding adding additional script and how it should be written. I've searched the forum and the web and just cant locate a viable solution. Code:
View 1 Replies
View Related
Dec 6, 2003
I know there is a million of them but here's a little calculator script I made just for kicks. Feedback is always appreciated, good or bad.
I think I did a pretty good job of mirroring the windows calculator functionality.
Basic keys are mapped (optionally) to the keyboard.
<html>
<head>
<title>Web Calculator</title>
<style type="text/css">
table
{
text-align:center;
background-color:#e5e5c5;
}
.button
{
width:55px;
font-weight:bold;
background-color:lightblue;
color:#333399;
}
.functbut
{
width:55px;
font-weight:bold;
background-color:lightblue;
color:red;
}
.back
{
width:115px;
font-weight:bold;
background-color:lightblue;
color:red;
}
.header
{
color:#333399;
}
#display
{
text-align:right;
}
</style>
<script type="text/javascript">
var find=document.getElementById;
var temp=0;
var total=0;
var which=0;
var m=0;
function Mplus()
{
m=parseFloat(find('display').value) + m;
find('memory1').value="M+*";
}
function Mclear()
{
m=0;
find('memory1').value="M+";
}
function Mrecall()
{
find('display').value=m;
}
function Mreplace()
{
m=find('display').value;
}
function showMe(num)
{
if(temp==0)
{
find('display').value=num;
temp=1;
}
else
{
find('display').value+=num;
}
}
function calcEm(num)
{
str=parseFloat(find('display').value);
if(which==0)
{
total=find('display').value;
temp=0;
which=num;
}
else if(which==1)
{
find('display').value=parseFloat(total)+ str;
total=find('display').value;
which=num;
temp=0;
}
else if(which==2)
{
find('display').value=parseFloat(total) * str;
total=find('display').value;
which=num;
temp=0;
}
else if(which==3)
{
find('display').value=parseFloat(total) / str;
total=find('display').value;
which=num;
temp=0;
}
else if(which==4)
{
find('display').value=parseFloat(total) - str;
total=find('display').value;
which=num;
temp=0;
}
}
function clearAll()
{
find('display').value=0;
which=0;
temp=0;
total=0;
}
function clearDisplay()
{
find('display').value="0"
temp=0;
}
function fractIt()
{
find('display').value=(1) / str;
}
function getPerc()
{
var d=find('display').value=str / 100;
calcEm(0);
}
function backSpace()
{
find('display').value=find('display').value.substring("0",find('display').value.length-1);
}
function getRoot()
{
find('display').value=Math.sqrt(find('display').value);
}
function invertIt()
{
var w=find('display').value.indexOf("-");
if(w==-1)
{
find('display').value="-" + find('display').value
}
else
{
find('display').value=find('display').value.substring("1",find('display').value.length);
}
}
function keyHandler()
{
keys=new Array();
keys[97]=("1");
keys[98]=("2");
keys[99]=("3");
keys[100]=("4");
keys[101]=("5");
keys[102]=("6");
keys[103]=("7");
keys[104]=("8");
keys[105]=("9");
keys[96]=("0");
keys[13]=("equal");
keys[107]=("plus");
keys[110]=("dot");
keys[109]=("minus");
keys[106]=("times");
keys[111]=("divide");
keys[110]=("dot");
keys[8]=("back");
keys[27]=("clear");
kc=window.event.keyCode;
if(keys[kc]!=undefined)
{
cColor('#333399');
setTimeout('cColor("lightblue")',100);
find(keys[kc]).click();
}
return false;
}
function cColor(bcolor)
{
find(keys[kc]).style.background=bcolor;
}
function keyOnOff()
{
var b=find('keychoice').checked
if(b==true)
{
document.onkeydown=keyHandler;
}
else
{
document.onkeydown="";
}
}
function checkHandler()
{
var e=find('keychoice').checked
if(e==false)
{
e=true;
}
else
{
e=false;
}
keyOnOff();
}
</script>
</head>
<body>
<table cellspacing="0" border="1">
<thead>
<th colspan="6" class="header">Web Calculator</th>
</thead>
<tr>
<td colspan="6"><input type="text" size="43" id="display" value="0."></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Backspace" id="back" class="back" onclick="backSpace()"></td>
<td colspan="2"><input type="button" id="ce" value="CE" class="back" onclick="clearDisplay()"></td>
<td colspan="2"><input type="button" id="clear" value="C" class="back" onclick="clearAll()"></td>
</tr>
<tr>
<td><input type="button" class="functbut" value="MC" onclick="Mclear();"></td>
<td><input type="button" class="button" id="7" value="7" onclick="showMe(ƍ')"></td>
<td><input type="button" class="button" id="8" value="8" onclick="showMe(Ǝ')"></td>
<td><input type="button" class="button" id="9" value="9" onclick="showMe(Ə')"></td>
<td><input type="button" class="functbut" id="divide" value="/" onclick="calcEm(3)"></td>
<td><input type="button" class="button" id="sqrt" value="sqrt" onclick="getRoot();"></td>
</tr>
<tr>
<td><input type="button" class="functbut" value="MR" onclick="Mrecall();"></td>
<td><input type="button" class="button" id="4" value="4" onclick="showMe(Ɗ')"></td>
<td><input type="button" class="button" id="5" value="5" onclick="showMe(Ƌ')"></td>
<td><input type="button" class="button" id="6" value="6" onclick="showMe(ƌ')"></td>
<td><input type="button" class="functbut" id="times" value="*" onclick="calcEm(2)"></td>
<td><input type="button" class="button" id="perc" value="%" onclick="getPerc()"></td>
</tr>
<tr>
<td><input type="button" class="functbut" value="MS" onclick="Mreplace();"></td>
<td><input type="button" class="button" id="1" value="1" onclick="showMe(Ƈ')"></td>
<td><input type="button" class="button" id="2" value="2" onclick="showMe(ƈ')"></td>
<td><input type="button" class="button" id="3" value="3" onclick="showMe(Ɖ')"></td>
<td><input type="button" class="functbut" id="minus" value="-" onclick="calcEm(4)"></td>
<td><input type="button" class="button" id="x" value="1/x" onclick="fractIt()"></td>
</tr>
<tr>
<td><input type="button" class="functbut" value="M+" id="memory1" onclick="Mplus();"></td>
<td><input type="button" class="button" id="0" value="0" onclick="showMe(Ɔ')"></td>
<td><input type="button" class="button" id="flop" value="+/-" onclick="invertIt()"></td>
<td><input type="button" class="button" id="dot" value="." onclick="showMe(this.value)"></td>
<td><input type="button" class="functbut" id="plus" value="+" onclick="calcEm(1)"></td>
<td><input type="button" class="functbut" id="equal" value="=" onclick="calcEm(0)"></td>
</tr>
<tr>
<td colspan="6" class="header">Num Pad On:<input type="checkbox"
id="keychoice" onclick="checkHandler();keyOnOff();"></td>
</tr>
</table>
</body>
</html>
Happy Calculating...
View 3 Replies
View Related
Jan 17, 2006
I'm attempting to create a shopping cart shipping calculator using the total $ provided by the cart itself (%total%). Basically the script needs to take the %total%, compare it to a bunch of arrays in the javascript, and provide the shipping charge as a percentage of the total. For example:
The cart total ends up being $15 (or %total%).
The set rates for shipping are:
Standard Shipping
$1 - $4.99 : 7.95% (of total)
$5 - $9.99 : 9.95%
$10 - $19.99 : 11.95%
Overnight Shipping
$1 - $4.99 : 9.95% (of total)
$5 - $9.99 : 11.95%
$10 - $19.99 : 19.95%
Two radio buttons would show the 2 shipping options and the shipping charges like this:
O Standard: $1.79
O Overnight: $2.99
View 3 Replies
View Related
Feb 19, 2009
I have a simple calculator written using javascript and html. I would like to make it such that when a link to the calculator is clicked, a pop up window with this calculator appears rather than referring a user to anew page.
View 2 Replies
View Related
May 26, 2010
I am working on a script that calculates the rental rate for a property. I currently have this code and form, which works as I wish it to.
Code:
<script type="text/javascript">
function roundCents(amount) {
[code]....
View 3 Replies
View Related
Oct 19, 2010
I am trying to make a calculator that calculates the amount of words inputted (words) and multiplying it with a variable decided by an If/Then statement. The way I want it to work is that if there is 1-10,000 inputted it multiplies whatever that amount is by .29, and if there is 10,000-20,000 by .26, and anything more than 20,000 by .24. This is what I have come up with so far:
Code JavaScript:
<script type="text/javascript">
function wordcount(){
[code]....
View 2 Replies
View Related
Feb 26, 2010
I have an online calculator in javascript which works in IE but not Moz.
site: [URL]
code:
function workit()
{
var xsource = new Array(0,0.09,0.1); // source language
var xtarget = new Array(0,0.09,0.10,0.12,0.14); // target language
[Code]....
View 4 Replies
View Related
Nov 24, 2010
I am trying to implement a time calculator onto my website with preset times to tell how long it would take to make troops. Say you want to make 100 Catapults and each Catapult takes one minute and ten seconds to make, I would like to be able to show the time in days /hours / minutes preferably in the format of 0:00:00. I would like it so someone can type in the amount of troops they want. There are Infantry that take 0:00:22, Cavalry that take 0:00:52, Archers that take 0:00:35 and Catapults that take 0:01:10.
View 2 Replies
View Related
Nov 23, 2011
Show a checkbox list with names of the coins. The user picks the coins he/she has and presses submit.
Then prompt boxes show up asking how many toonies you have (if the user selected toonies) and it does that for each one that has been checked marked.I've tried this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
[code]....
View 11 Replies
View Related
May 22, 2010
I'm trying to make a calculator in HTML/Javascript but I'm having trouble with the memory buttons. Here is the code:
<html>
<head>
<title>Env X Software | Env X Online Calc</title>
[code]....
View 9 Replies
View Related
Mar 29, 2011
I have a text field with a numberpad below it, I got the numbers to show up in the text field, but am unsure as to how when I hit the enter button - it would store them in a variable?...I am also wondering as to how it would store current value and then allow me to input another value(maybe on the next page) and either subtract or add to it(the first value that is stored).I need the calculator to be like a numberpad/money calculator, so when the user will enter a specific amount(stored in variable), (there will be two decimal places for currency(not sure how to get this working)i want the "point" to be there when they enter in numbers).then they add in another amount, how would i subtract/add this to the first stored value?
<html>
<head>
<script type = "text/javascript">
[code]....
View 3 Replies
View Related
Nov 4, 2003
Where could I find a mortgage calculator script I could place on my website? I found a really cool one at www.dave.imarc.net/php free to use but I have a hard time understanding how to install it. I really don't even know what php is.
Could someone maybe guide me out of this programming lingo darkness?
View 2 Replies
View Related
May 17, 2004
Here's the deal...I have a form in my Coldfusion page that is a financial calculator (you type in the amount of the goods and the interest and it computes your monthly payments. It drops the numbers into the input fields in the form). This form uses javascript to do the calculations. So here is the problem.
I have three columns on my site. The left column has a couple of short forms that use the "CFFORM" tag. It seems that when i have the CFFORM tag in the page for whatever the reason the form can't do that math anymore. When I remove the CFFORM from the page it works fine.
What is the work around for this and why is there even a conflict between the two? I am closing all of my tags form tags.
I also use ColdFusion includes in the page, are they going to cause problems with the script too?
View 2 Replies
View Related
Apr 7, 2011
so i am working on a calculator but i am having trouble with the % buttonif i do 200*50% it should be 100, but now it says 0.5the function code:
function PercentButton() {
if(NewNumber != "blank") {
Number2 *= .01;
[code]....
View 2 Replies
View Related
Apr 14, 2011
I have to code something where the input would be the age (in years) and the output would be the age (in days). I'm not sure what I did wrong, but it's not working,
[Code]...
View 4 Replies
View Related
Apr 21, 2011
I have one interesting problem of one of my project. So i have three function where calculate two different value. So how look HTML code
[Code]...
View 1 Replies
View Related
Jan 9, 2011
I would like to create a calculator which can help parents when they calculate their student's school fees on our school's joomla web site. Ive attached our school's fee table.
View 1 Replies
View Related
Jul 20, 2005
I have to integrate FedEx or UPS's Rate Calculator with an eCommerce web site. I have a web site which offers some products for sale. The price of the products is being charged to customer. But now I want to calculate the amount of shipping depending on the postal code in USA and Canada only with FedEx or UPS and add to the total amount. I looked the tools offered by FedEx and UPS, but still I could not integrate with the web site. Even after following the documentation. I want to do like within one window or an pop-up window of browser, but the goal is depending on the postal
code the amount of shipping should be calculated and added to chargeable amount.
View 2 Replies
View Related
Sep 19, 2010
I'm getting started at javascript and jQuery, I want to make a calculator for my services, for example, checking a box will add value to a total.For example theres a textbox that asks how much gallons of paint will be used, the value of each gallon is 30 dollars, so the user can write for example 2 on the input and a div will output 60. I think that would be made with .change(), but in the demo of the documentations appears a selection list, and I can't figure out how to make an input work like that.
View 1 Replies
View Related
Aug 2, 2010
I want to accept both commas and dots in my calculator. How to do this?
function compute(form)
{
get Index value for width
var wt = (form.width.options.selectedIndex)
[Code]....
View 6 Replies
View Related