I am trying to do what I thought would be very simple.
I am trying to create a variable that I will increment to reference a field on a form but I keep getting the following error:”Value is null or not an object”. Here is a code sample:
function timeValidation()
{
recNum = document.control.rCount.value;
i = recNum;
for (x = 1; x <= i; x++)
{
t = “stTime_”;
t = t + x;
alert(t);//t = stTime_1
time = document.control.t;
var h = time.value.indexOf(“:”, 0);
…….so on and so forth.
*The form’s name is ‘control’. I have up to 54 form fields named ‘stTime_1’, ‘stTime_2’ and so on. I am just trying to loop through them by concatenating x to ‘stTime_’ but when I do a document.control.t the value is null. When I do a document.control.stTime_1 I get the form value. I have done alerts and I know that t the first time through the loop t = ‘stTime_1’. Any ideas on how I can make document.control.t reference stTime_1 correctly would be greatly appreciated.
Thanks to anyone that can help!!!!!