SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't figure out how to do a total function

    I am attempting to create a total function.

    It needs to be able to take the
    Quantity of Basic multiply it by the price of Basic
    Quantity of Pro multiple it by the price of Pro
    Then add both to get the total, but I cannot seem to correctly do it because sometimes someone may choose to have nothing for Basic or they may nothing for Pro.

    PHP Code:

    <script type="text/javascript" language="JavaScript">

    var 
    priceBasic;
    var 
    pricePro;
    var 
    basicQty 0;
    var 
    proQty 0;
    var 
    Bqty;
    var 
    Pqty;

    function 
    total() {
    }

    function 
    setPriceBasic(price) {
        var 
    url 'Ajax.php';
        
    priceBasic price;
        var 
    params 'price=' price;
        var 
    ajax = new Ajax.Updater(
        {
            
    success'priceBasic'
        
    }
        ,
    url,
        {    
            
    method'get'
            
    parametersparamsonFailurereportError
        
    });
        
    total();
    }


    function 
    setPricePro(price) {
        var 
    url 'Ajax.php';
        
    pricePro price;
        var 
    params 'price=' price;
        var 
    ajax = new Ajax.Updater(
        {
            
    success'pricePro'
        
    }
        ,
    url,
        {    
            
    method'get'
            
    parametersparamsonFailurereportError
            
    });
        
    total();
    }

    function 
    reportError(request) {
    $F('price') = "Error";
    }

    function 
    setQtyBasic() {
        
    Bqty document.qty.qty.value;
        var 
    url 'Ajax.php';
        var 
    params 'qty=' Bqty '&price=' priceBasic;
        var 
    ajax = new Ajax.Updater(
        {
            
    success'priceBasic'
        
    }
        ,
    url,
        {    
            
    method'get'
            
    parametersparamsonFailurereportError
        
    });
        
    document.getElementById('basic').innerHTML '<strong>Basic:</strong> ' Bqty;
        
    total();
    }

    function 
    setQtyPro() {
        
    Pqty document.qty.qty1.value;
        var 
    url 'Ajax.php';
        var 
    params 'qty=' Pqty '&price=' pricePro;
        var 
    ajax = new Ajax.Updater(
        {
            
    success'pricePro'
        
    }
        ,
    url,
        {    
            
    method'get'
            
    parametersparamsonFailurereportError
        
    });
        
    document.getElementById('pro').innerHTML '<strong>Pro:</strong> ' Pqty;
        
    total();
    }
    </script> 

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, to do the Ajax I am using prototype !


Bookmarks

Posting Permissions

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