Sir,
As per your suggestion i changed the Fields name to DP.0, DP.1 ..... DP.27
below is the script i am trying to execute after incorporating the changes suggested by you, but it is not printing anything.....
var maxValid = false;
var max = 0;
for (var i=0; i<=28; i++)
{
var val = parseInt(this.getField("DP." + i).value);
if (!isNaN(val)) // we have a valid number
{ if (maxValid == true)
{ // this is the first valid value
max = val;
maxValid = false;
}
else
{
max = Math.max(max, val);
}
}
}
if (maxValid)
event.value = max;
else
event.value = "";
If you have fields named from 0 to 27, you cannot run your loop from 0 to 28 - unless you have an exception handler. You need to limit the loop to run from 0 to 27. There is another problem with your code which I did not see last time around: You initialize maxValid to "false", but then you test for "true" inside your loop (and set it to "false" if it was true). You don't have a valid value yet on the first iteration, so you need to check for "false" and set the variable to "true" inside the "if" block.