469,571 Members | 1,533 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,571 developers. It's quick & easy.

INPUT type=image in IE

Hi all,

I noticed that the image input type does not show up in the elements
array (IE 6.0).

<FORM name=myForm>
<INPUT name=rads id=check1 type=radio value=val1>
<INPUT name=rads id=check2 type=radio value=val2 checked>
<INPUT name=rads id=check3 type=radio value=val3>
<INPUT name=rads id=check4 type=radio value=val4>

<INPUT name=imgIn type=image src=web.gif>
<INPUT type=button name=somethin>
</FORM>

If I have this HTML code, the myForm.elements.length is 5, instead of
the expected 6. You can click on the image in this case, and it acts
like a submit button... proof that the broser recognizes it as part of
the form.

So, if I call myForm.elements[4], I get the button, not the image.

It seems goofy to me, and I cannot find any documentation that explains
why this is.

Of course, I can get access to the object in many other ways... I am
just curious if the is an IE bug.

Brian

Jul 23 '05 #1
1 3940


Brian Genisio wrote:

I noticed that the image input type does not show up in the elements
array (IE 6.0).

<FORM name=myForm>
<INPUT name=rads id=check1 type=radio value=val1>
<INPUT name=rads id=check2 type=radio value=val2 checked>
<INPUT name=rads id=check3 type=radio value=val3>
<INPUT name=rads id=check4 type=radio value=val4>

<INPUT name=imgIn type=image src=web.gif>
<INPUT type=button name=somethin>
</FORM>

If I have this HTML code, the myForm.elements.length is 5, instead of
the expected 6. You can click on the image in this case, and it acts
like a submit button... proof that the broser recognizes it as part of
the form.

So, if I call myForm.elements[4], I get the button, not the image.

It seems goofy to me, and I cannot find any documentation that explains
why this is.

Of course, I can get access to the object in many other ways... I am
just curious if the is an IE bug.


Do you get a different result for Mozilla or Netscape browsers? I don't
think so. Somehow when Netscape 2 or 3 introduced the elements
collection for <form> element objects <input type="image"> elements were
not included and most browsers stick with that (odd) tradition. With
old Netscape's (2, 3, 4) the <input type="image"> was therefore not
scriptable at all but nowadays you can use getElementsByTagName or
getElementById to access it

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mark | last post: by
7 posts views Thread by b2b2u | last post: by
1 post views Thread by champ.supernova | last post: by
3 posts views Thread by jackiepatti | last post: by
8 posts views Thread by John | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.