Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiplying Variables Not Alerting
    primarykey
    data
    text
    <p>I have a script which calls variable values from input fields and multiplies them, At the minute my function isnt executing, Im getting no alert neither, I think this is because of my if statement, can anybody see whats going wrong? </p> <pre><code>function Calculate() { var ContentMinutes = document.getElementById ("ContentMinutes").value; var ContentMinutesSelect = document.getElementById('ContentMinutesDD') .options[document.getElementById('ContentMinutesDD').selectedIndex].value 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.toFixed(2) + 'Estimated Core Hours = ' +EstimatedCoreHours); 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); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload