for (var k = 0; k < frmdepreforecast.hdnLine.value; k++)
{
if(isNaN("document.frmdepreforecast.txtForecast" + k + ".value"))
{
errorMsg += "\n\t PleaseInsert Number to Forecast Value";
}
}
แบบนี้ก็ไม่ได้
for (var k = 0; k < frmdepreforecast.hdnLine.value; k++)
{
if(isNaN(document.getElementById("frmdepreforecast.txtForecast" + k ).value))
{
errorMsg += "\n\t PleaseInsert Number to Forecast Value";
}
}
แต่ถ้าไม่ใช้ k แต่กำหนดตัวเลขไปเลยมันทำงานได้
for (var k = 0; k < frmdepreforecast.hdnLine.value; k++)
{
if(isNaN(document.frmdepreforecast.txtForecast1.value))
{
errorMsg += "\n\t PleaseInsert Number to Forecast Value";
}
}
for (var i = 1; i <= frmdepreforecast.hdnLine.value; i++)
{
if(isNaN(eval("document.frmdepreforecast.txtForecast" + i ).value))
{
errorMsg += "\n\t" + eval("document.frmdepreforecast.txtForecast" + i ).value + " is not number.";
eval("document.frmdepreforecast.txtForecast" + i ).focus();
}
}