Hi,
I was wondering what I am doing wrong here, I want to be
able to generically save the contents of a form to a cookie, without hardcoding the names of the fields in my
code. I saw some examples where the script looped through
the elements of a form and extracted the information using
the for loop counter. I am trying this with the code below
and its not working, its says elements[..] is null or not an object. When i watch it in the debugger it says the element is null. However, when I keep the same code, but hard code a 0 or a 3 in the [arraycounter] so its elements[0] instead of elements[j] where j=0, then it works, but that certainly defeats the purpose of having a generic function. has this happened to someone else also ?
thanks .... code below
ps elements.length does report back the correct number of elements in the form. Its just inside the for loop using an icrementer that elements[..] is null
with(currentForm)
{
numElements = elements.length;
for(j=0; j<numElements; j++);
{
currentType = elements[j].type;
if(currentType == "submit" || currentType == "SUBMIT"
{
//DON'T SAVE VALUE
}
else
{
currentName=elements[j].name;
currentValue=elements[j].value;
setCookie(currentName, currentValue);
}//else
}//for
}//with
I was wondering what I am doing wrong here, I want to be
able to generically save the contents of a form to a cookie, without hardcoding the names of the fields in my
code. I saw some examples where the script looped through
the elements of a form and extracted the information using
the for loop counter. I am trying this with the code below
and its not working, its says elements[..] is null or not an object. When i watch it in the debugger it says the element is null. However, when I keep the same code, but hard code a 0 or a 3 in the [arraycounter] so its elements[0] instead of elements[j] where j=0, then it works, but that certainly defeats the purpose of having a generic function. has this happened to someone else also ?
thanks .... code below
ps elements.length does report back the correct number of elements in the form. Its just inside the for loop using an icrementer that elements[..] is null
with(currentForm)
{
numElements = elements.length;
for(j=0; j<numElements; j++);
{
currentType = elements[j].type;
if(currentType == "submit" || currentType == "SUBMIT"
{
//DON'T SAVE VALUE
}
else
{
currentName=elements[j].name;
currentValue=elements[j].value;
setCookie(currentName, currentValue);
}//else
}//for
}//with