473,654 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form images don't appear in form.elements

Apparently, form elements of type

<input type="image" src="...>

are not included in the form's elements[] collection.

I don't understand why not; according to DOM2, all form control
elements in the form are part of the elements collection. Further,
this element doesn't appear in the (DOM0) document.images
collection either; so it's really not well-accounted for.

And, to the contrary, the <input type="image"> element *does* have
a 'form' property, whose value is its parent form. This seems
completely wrong: if you count the nodes in form.elements, it
really should be equal to the number of nodes that reference
the form element in their form property.

Is there an explanation for this, or was this behavior chosen
strictly to mimic Internet Explorer's behavior? Or, am I doing
something wrong?

Thanks,

hj

Illustration:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- This behavior doesn't seem to be affected if I
omit the DTD, to fall back to quirks mode -->
<html><head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<title>Img form elements</title>
<script type="text/javascript">
function ecount(f) {
var collection,i,no de;
alert(f.element s.length + " elements in form, and \n" +
document.images .length + " images in document.images ");
collection = f.getElementsBy TagName('*');
alert(collectio n.length + " descendant nodes in form");
for (i=0; i<collection.le ngth; i++) {
node = collection[i];
alert("Form descendant node: '" + node.nodeName +
"'.form='" + node.form + "'");
}
return false;
}
</script></head><body>
<h1>Img form elements</h1>
<div>
<form action="" onsubmit="retur n ecount(this)">
<p>There are 2 elements in this form:<br><br>
&lt;input type="text"&gt; : <input type="text" name="txt" onblur="ecount( this.form)"><br >
and &lt;input type="image"&gt ;: <input type="image" src="../images/awki.png">
</p><p>
Click the image, or blur() the text input to count fields in the
form's elements array.</p>
</form></div>
</body></html>
Jul 23 '05 #1
1 1617
Howard Jess wrote:
Apparently, form elements of type

<input type="image" src="...>

are not included in the form's elements[] collection.

I don't understand why not; according to DOM2, all form
control elements in the form are part of the elements
collection.
They don't always not appear in the elements collection, but it would be
reasonable to say that it would not be a good idea to expect to be able
to find them there (as they commonly will not be present).
Further, this element doesn't appear in the (DOM0)
document.images collection either;
It would be unexpected for them to appear in - document.images - as it
is explicitly a collection of IMG elements, no elements that happen to
be displaying images (such as maybe OBJECT).
so it's really not well-accounted for.
It is certainly a unhelpful peculiarity where forms are concerned.

<snip> Is there an explanation for this, or was this behavior
chosen strictly to mimic Internet Explorer's behavior?
Or, am I doing something wrong?

<snip>

I think you will find that this behaviour originates with a Netscape
browsers. Netscape 4 had no means of referencing these elements (as they
did not even support event handlers), and that may have also been true
for earlier versions (thus pre-dating scriptable IE versions).

Richard.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2220
by: twopeak | last post by:
Hello I'm making a script, that should allow users to change a select box, and this changes the alt and the src of several images. I have made a script (see under) that exactly does what it's supposed to do! My problem is that this was just a page to test, now I'm implementing it in my page And as soon as the select box is inside the form, when I change the select I get an error "this object doesn't support this property"
5
6084
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the Internet. Specifically, marking up a document that will contain multiple related form controls (intended exclusively for client-side scripting) that would never be intended to be submitted. I realise that that concept is a non-starter in an Internet...
1
3038
by: Dave | last post by:
Hi all, I was trying to make an image submit button with a rollover and discovered to my suprise that there is no way to access a form element of the "image" type. I tried specifying it by name and also by the elements array with no luck. Even weirder, I can sandwich an image button in between other input types and then write a script diplaying the contents of the elements array and it acts as if the image button does not exist at all!...
0
2694
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main form. Then I have 3 pages on a tab control ( 4 if the type of candidate validates that is is to be shown) Each page has a subform. The subforms can be either single or continuous, I think I am still deciding what I want to lock down this entry...
10
1887
by: Mohit Gupta | last post by:
Hello Friends I have written a simple HTML page in aspx I have added form elements like "textBox", "Hidden fields", "images", "radio buttons" to the html form I am posting the data back to the same page Is there a way to know the "Type" of a form element upon post back. Meaning in the code behind file of the page, is there a way to find the "Type" all the form elements ("textBox", "Hidden fields", "images", "radio buttons" etc Any...
3
3820
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a nutshell when testing my ASP.NET (localhost) apps images randomly don't load on the page. Examining the IIS logfile shows the missing images give 401 or 403 errors. Here's an example - 10:15:47 127.0.0.1 GET...
25
2468
by: Dave | last post by:
Hello. In trying to get an anchor element to stylistically match an input or button element, I find that the button and input cannot be styled according to the 2.1 CSS spec. For example, I expected this ruleset: ..but { display: block; background-color: red; font-size: 14px; text-decoration: none; line-height: 16px; width: auto; height: 16px; padding: 0; margin: 0;
11
2234
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the string "d" then I want to emable rblDebts which is disabled when the page loads. This part is not working (no errors) and I'm not sure why. Thanks. <script type="text/javascript" language="JavaScript"> <!-- Begin oldvalue = "";
1
2621
by: jeddiki | last post by:
Hello, I have made a nice opt-in form and tested it in Moz FF and it looks fine. But in IE the elements don't line up properly. I think I am nearly there but can not get these elements straight - can you see what I have missed ?
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.