2011-05-24 90 views
0

我有这个函数调用文档ID的值,并定义了一些变量。第二个警告不起作用

这一切似乎工作正常besindes变量已定义和第二个警告框不出现,任何想法为什么?

function Calculate() { 
var ContentMinutes = document.getElementById ("ContentMinutes").value; 
var NoOfFrames = 5; 
var EstimatedCoreHours = document.getElementById ("EstimatedCoreHours").value; 
var ServiceLevel=document.getElementById('SerivceLevelDD').options[document.getElementById('SerivceLevelDD') .selectedIndex].value 
var RenderHours = 1; 
var CoresInTest = 2; 

var EstimatedTotal = GetNumeric(ServiceLevel) * GetNumeric(EstimatedCoreHours); 
alert('hi = '+EstimatedTotal.toFixed(2)); 

var EstimatedCoreHours = GetNumeric(NoOfFrames) * GetNumeric(RenderHours) * GetNumeric(CoresInTest); 
alert(' = '+EstimatedCoreHoursTotal.toFixed(2)); 
} 

function GetNumeric(val) { 

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

对不起,我忘了寄存器...

我评论了 'VAR EstimatedCoreHours =的document.getElementById( “EstimatedCoreHours”)值;'。变量并不需要它,仍然无法howerver工作...

+0

我冒昧地合并你的两个账户,并保留一个与它的问题。 – 2011-05-24 11:53:54

回答

2

你有

EstimatedCoreHours = 

但提醒您:

EstimatedCoreHoursTotal 

所以,我猜你想变化:

var EstimatedCoreHours = GetNumeric(NoOfFrames) * GetNumeric(RenderHours) * GetNumeric(CoresInTest); 

到:

var EstimatedCoreHoursTotal = GetNumeric(NoOfFrames) * GetNumeric(RenderHours) * GetNumeric(CoresInTest);