Connecting Tech Pros Worldwide Help | Site Map

INPUT type=image in IE

  #1  
Old July 23rd, 2005, 11:41 AM
Brian Genisio
Guest
 
Posts: n/a
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

  #2  
Old July 23rd, 2005, 11:41 AM
Martin Honnen
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
input type= image not working in IE shane3341436 answers 0 September 22nd, 2007 11:44 AM
x,y coordinates from an <input type='image'> jackiepatti@gmail.com answers 3 August 24th, 2006 10:15 AM
INPUT type=image dwa answers 1 November 18th, 2005 04:18 AM
Programatically click <INPUT type=image ...> element Csaba2000 answers 4 July 20th, 2005 01:06 PM