#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    4
    Rep Power
    0

    Javascript not working in IE 8, but fine in other browsers


    Hi there,

    I have some javascript code that helps work out Gross Profit - it works fine in every other browser, but it doesn't seem to calculate in IE 8. I've had a look on Google and it might be something to do with the "getelementbyid" (i could be wrong, so apologies). Below is the javascript code (there is additional styling code etc, but i wont include that). Would anyone be able to have a look and suggest what the issue could be?

    I'm not fantastic in javascript im afraid, so am struggling!

    Code:
    <script type="text/javascript"> 
    
    function calcGProfit() {   
    var caseprice = document.getElementById('CasePrice').value * 1;   
    var unitsPerCase = document.getElementById('UnitsCase').value * 1;   
    var percentProfit = document.getElementById('percGP').value / 100;   
    
    costPrice = caseprice / unitsPerCase;   
    document.getElementById('costPrice').value = costPrice.toFixed(2);        
    var sellCase = costPrice / (1 - percentProfit) * unitsPerCase;   
    document.getElementById('sCase').value = sellCase.toFixed(2);      
    var sell$ = (sellCase / unitsPerCase);   
    document.getElementById('sellPricexVAT').value = sell$.toFixed(2);   
    var sell$$ = sell$ * (1 + 0.20);   
    document.getElementById('sellPriceVAT').value = sell$$.toFixed(2);   
    var Cmargin = sell$ - costPrice;   
    document.getElementById('cashMargin').value = Cmargin.toFixed(2);  } </script> 
    
    <script type="text/javascript"> 
    function calcNewProfit() {   
    var newSellPrice = document.getElementById('sellPriceNew').value * 1;      
    var sellEx = newSellPrice / (1 + 0.20);   
    document.getElementById('sellPricexVAT1').value = sellEx.toFixed(2);      
    var equivGP = (sellEx - costPrice) / sellEx * 100;   
    document.getElementById('equivGP').value = equivGP.toFixed(2);      
    } 
    </script>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,188
    Rep Power
    184
    Look at your IE8 script console under your "Developer Tools" and see what kind of error(s) it is giving you, from your script.

IMN logo majestic logo threadwatch logo seochat tools logo