...

View Full Version : Help with reset button



Secyrb
12-18-2005, 09:40 PM
Here is my code i cant seem to get the reset button to work??


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Price Quote</title>
</head>


<script>
function doCalculation()
{
var g = parseFloat(document.getElementById('originalGunPrice').value);
var s = parseFloat(document.getElementById('shipping').value);
var x = (g * 1.1 * 1.0725) + s + 25;
x=Math.round(x*100)/100
document.getElementById('calculatedPrice').value = x;
return false;
}
</script>
</head>

<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="left">
Gun Price&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input id="originalGunPrice" type="text" value="0">
</p>
<p>
10% Handling&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="h" type="text" id="10%" value="10%" readonly="true">
</p>
<p>
Tax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="t" type="text" value=".0725" readonly="true">
</p>
<p>
Shipping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input id="shipping" type="text" value="0">
</p>
<p>
DROS Fees&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="f" type="text" value="+$25" readonly="true">
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>
<input name="Calcuate" type="submit" onClick="doCalculation();">
<input name="reset" type="reset">

</p>
<p>
Price Quote:
<input id="calculatedPrice" type="text">
</p>
<p>&nbsp;</p>

</body>
</html>

Osiris
12-18-2005, 09:42 PM
I'm about 95% sure your problem there is that it all has to be enveloped in a <form>. Try putting that in. If it doesn't work, you could always just make a Javascript function to do it instead.

Secyrb
12-18-2005, 09:47 PM
Thanks, that makes the reset button work lol but now when you hit the submit button it just refreshes the page and resets everything??

Osiris
12-18-2005, 09:51 PM
Oops, my bad. Add


onSubmit="return false;"

to the end of your opening <form> tag. That'll fix it.

Secyrb
12-18-2005, 10:03 PM
thanks so much!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum