Connecting Tech Pros Worldwide Forums | Help | Site Map

INPUT type=image in IE

Brian Genisio
Guest
 
Posts: n/a
#1: Jul 23 '05
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


Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: INPUT type=image in IE




Brian Genisio wrote:

[color=blue]
> 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.[/color]

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/

Closed Thread