...

View Full Version : How can I auto update total in Firefox?



Local Hero
05-22-2005, 06:13 PM
I have a function that works fine, except in firefox you can change the quantity and it won't update the total. You have to reselect the radio buttons to update. I want it to either have an onBlur event on the quantity box, or a button that will update the total. Any ideas?

<html> <head> <title></title>
<script language="JavaScript" type="text/javascript">
function DoSilk(x){
if (1<=x && x<=20) y=(0.0524*x*x)-(2.1391*x)+(32.04575);
if (20<x && x<=50) y=39.779 * Math.pow(x, -0.4532);
if (50<x && x<=288) y=(10.4835 * Math.pow(x, -0.121635))+.2;
if (288<x && x<=4200) y=(10.4835 * Math.pow(x, -0.121635))+.2;
if (4200<x) y=4;
}
function DoHeat(x){
if (1<=x && x<=100) y=(10.87*Math.pow(x,-.17))+1.03;
if (100<x) y=6;
}
function Radio(obj){
y='?';
x=document.forms.formjunk.product_options_amountzz.value;
rbs=obj.getElementsByTagName('INPUT');
if (rbs[0].checked){
DoSilk(x);
}
if (rbs[1].checked){
DoHeat(x);
}
if (rbs[2].checked){
y=4;
}
document.getElementById('price').value=y;
document.forms.orderform_16180.subtotal.value = (document.forms.orderform_16180.price.value*document.forms.formjunk.product_options_amountzz.value);
}
</script>
</head> <body>
<P>Quantity</P>
<FORM name="formjunk" method="post" action="">
<INPUT type="text" name="product_options_amountzz" onBlur="Radio(radioFred)">
</form>
<P>
<FORM name="form15" method="post" action="">
<span id="radioFred" onclick="Radio(this);" >
Silk Screen<input type="radio" name="radioFred"> <br>
Heat Transfer<input type="radio" name="radioFred"><br>
Blank<input type="radio" name="radioFred"> <br>
</span>
</form>
<FORM name="orderform_16180" method="post" action="">
Price Per<input name ="price" id="price" size="10"> <br>subtotal<input name="subtotal" id="subtotal" size="10">
</FORM>
</body>
</html>

vwphillips
05-22-2005, 10:34 PM
nearly but function Radio requires the span object

try



<INPUT type="text" name="product_options_amountzz" onBlur="Radio(document.getElementById('radioFred'))">

Local Hero
05-23-2005, 03:10 AM
That did it! Thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum