Connecting Tech Pros Worldwide Help | Site Map

INPUT type=image in IE

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 10:41 AM
Brian Genisio
Guest
 
Posts: n/a
Default 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


  #2  
Old July 23rd, 2005, 10:41 AM
Martin Honnen
Guest
 
Posts: n/a
Default 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/

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.