Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    Utah
    Posts
    65
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Arrow How can I auto update total in Firefox?

    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>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    nearly but function Radio requires the span object

    try

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

  • #3
    New Coder
    Join Date
    May 2005
    Location
    Utah
    Posts
    65
    Thanks
    6
    Thanked 0 Times in 0 Posts
    That did it! Thanks again.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •