Jump to content

Variable IF ELSE


Recommended Posts

Hi all, im trying to set a variable using an if else statement only its breaking my entire code and not executing anything, Can anybody see why?

 

function Calculate() {

   var ContentMinutes = document.getElementById ("ContentMinutes").value;
   var ContentMinutesSelect = document.getElementById('ContentMinutesDD').options[document.getElementById('ContentMinutesDD').selectedIndex].value
   var RenderingHours=20;
   
   if (ContentMinutesSelect == 0.0166)
   {
   var RenderingHours = 10;
   var VideoHours = 5;
   var VideoSeconds = 1;
   document.getElementById("RenderHours").innerHTML=RenderingHours;
   document.getElementById("VideoHours").innerHTML=VideoHours;
   document.getElementById("VideoSeconds").innerHTML=VideoSeconds;
   }
   else if (ContentMinutesSelect == 0.0003)
   {
   var RenderingHours = 1540;
   var VideoHours = 54;
   var VideoSeconds = 1;
   document.getElementById("RenderHours").innerHTML=RenderingHours;
   document.getElementById("VideoHours").innerHTML=VideoHours;
   document.getElementById("VideoSeconds").innerHTML=VideoSeconds;
   }
   else
   {
   var RenderingHours = 6410;
   var VideoHours = 345;
   var VideoSeconds = 124;
   document.getElementById("RenderHours").innerHTML=RenderingHours;
   document.getElementById("VideoHours").innerHTML=VideoHours;
   document.getElementById("VideoSeconds").innerHTML=VideoSeconds;
   }
   
   var NoOfFrames = document.getElementById ("NoOfFrames").value;
   //var EstimatedCoreHours = document.getElementById ("EstimatedCoreHours").value;
   var ServiceLevel = document.getElementById('SerivceLevelDD').options[document.getElementById('SerivceLevelDD').selectedIndex].value;
   var RenderHours = 1;
   var CoresInTest = document.getElementById ("CoresInTest").value;
   
   var EstimatedCoreHours =  GetNumeric(NoOfFrames) * GetNumeric(RenderingHours) * GetNumeric(CoresInTest);
   
   var EstimatedTotal =  GetNumeric(ServiceLevel) * GetNumeric(EstimatedCoreHours);
   
   alert('Estimated Cost' +EstimatedTotal);
   
   document.getElementById("EstimatedCoreHours").innerHTML=EstimatedCoreHours.toFixed(2);
   document.getElementById("EstimatedTotal").innerHTML=EstimatedTotal.toFixed(2);
   
   document.getElementById("EstimatedCoreHours").style.backgroundColor="yellow";
   document.getElementById("EstimatedTotal").style.backgroundColor="yellow";
}

function GetNumeric(val) {

    if (isNaN(parseFloat(val))) {
    return 0;
    }
return parseFloat(val);
}

Link to comment
https://forums.phpfreaks.com/topic/237324-variable-if-else/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.