I created this test routine to return the form containing a certain
input element:
function GetElementForm(element)
{
// Return the form that contains element.
var myElement = element;
while (myElement)
{
myElement = myElement.parentNode;
if (myElement)
{
var sTagName = myElement.tagName;
if (sTagName)
{
if (sTagName.toLowerCase() == "form")
{
break;
}
}
}
}
return myElement;
}
This seems to work for "well formed" HTML, but fails for example, when
a form is defined within a table.
Is there a technique that works reliably?
Thanks,
Frank