Sea Sun

Sea Sun

  • NA
  • 10
  • 4.1k

Getting result in box from a function with conditions

Mar 14 2015 12:25 PM

Need help with getting the answer to commission taking into account some consitional statements and the total cost

I have this but it's not working


<script type="text/javascript">
    function sumUp() {
        var total = (document.getElementById("price1").value * document.getElementById("input1").value) + (document.getElementById("price2").value * document.getElementById("input2").value) + (document.getElementById("price3").value * document.getElementById("input3").value)
        document.getElementById("total").value = total;
  }
 function multiply()
   {
  
  if(total < 10000)
  {
   commission = total * 0.001;
  }
  else
  {
   commission = total* 0.0008;
  }
   commission +=5;
   
   var total_commission =commission+total;
      document.getElementById("commission").value = total_commission;
 }




the conditions are:

0.1% of the trade value if the total trade value is less than $10,000
 0.08% of the trade value if the total trade value is greater than or equal to $10,000
  The minimum commission is $5


Answers (6)