
01-08-2009
|
|
|
|
IE referencing dhtml object directly via ID fails when wrapped FOR
I have a very simple page with an HTML FORM that has a SELECT element.
When I try to access the element via its ID or NAME it will come back as
undefined. If you remove the surrounding FORM tag - it is a reference to the
DOM object.
Why does adding the form tag make the element inaccessible via its ID??
Thanks for any help!
Hiedi
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<FORM name= "testForm1" ACTION="" METHOD="POST">
Enter your name: <INPUT NAME="FName"><BR>
Favorite Ice Cream Flavor:
<SELECT ID="Flavor" NAME="Flavor">
<OPTION VALUE="Chocolate">Chocolate
<OPTION VALUE="Strawberry">Strawberry
<OPTION VALUE="Vanilla" SELECTED>Vanilla
</SELECT>
<P><INPUT TYPE=SUBMIT>
</FORM>
</HTML>
<SCRIPT >
alert(testForm1.Flavor.value);
alert(Flavor.value);
</script>
|