OZONE Asylum
Forums
DHTML/Javascript
Error: document.form has no properties
This page's ID:
27669
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Some things: - Compliant browsers use [b]id[/b] and then [b]name[/b] in the forms collection. - Traditionally browsers used [b]name[/b], and some browsers haven't yet started supporting [b]id[/b] only. - There are two good ways of doing it. One way is to use [b]document.getElementById('dice_toss')[/b]; the other way is to use [b]document.forms['dice_toss'][/b] that the form is given that [b]name[/b] and just not [b]id[/b]. In any ways, you need to understand that [b]name[/b] means different things depending on what elements it's used on, and it is treated differently in different situations. HTML/XHTML distinctions: - On form controls: The [b]name[/b] attribute is the form control name, in other words it is the label that will be given to the control value when sending it to the server. Checkbox and radio controls may share names, but all other controls must be unique *within the form*. The [b]id[/b] attribute on the hand must be a unique identifier *within the document*. The [b]name[/b] attribute allows several charachters that the [b]id[/b] attribute does not, but that's okay since they have entirely different purposes and use. There is no need to have the same [b]id[/b] and [b]name[/b] value here. The [b]id[/b] attribute is made for client side handling while the [b]name[/b] attribute is for the server when recieving the form. Form controls that the user can change the state of, as well as hidden controls, MUST have a [b]name[/b] attribute. (As per the HTML4.01 spec.) - On non-form-control, non-frame elements: [b]name[/b] and [b]id[/b] share namespace and are both treated as if they were [b]id[/b]s, each element may only be given one unique identifier and thus they may not contain different values. The [b]name[/b] attribute allows some characters that the [b]id[/b] attribute does not, these should be avoided. This category includes the [b]form[/b] element. - and I'll skip explaining the frame elements... DOM/JavaScript distinctions: - [b]document.[i]form_name[/i][/b] access is proprietary. It's ubiquitous but discouraged and should be avoided. - [b]document.forms['[i]form_name[/i]'][/b] syntax is on the other hand DOM0 and W3C DOM and is recommended. The only caveeat is that some browsers haven't started supporting [b]id[/b] for form names. - [b]document.getElementById('[i]fom_name[/i]')[/b] is supported by all browsers, and should work in all browsers as long as you use the [b]id[/b] attribute for the form name. - [b]document.getElementsByName[/b] is horribly broken and implemented differently in ALL browsers to date (Try it with all possible types of id/name combos in a document and html/xhtml/xml content types and you'll see a bloody mess of different behaviors, sometimes different in different versions of the same browser.). Not to speak of the fact it's intended only for form control names, but that distinction doesn't seem to take place in browsers. -- var Liorean = { abode: "[sigrotate][url]http://liorean.web-graphics.com/[/url]|[url]http://codingforums.com/[/url]|[url]http://web-graphics.com/[/url][/sigrotate]", profile: "[url]http://codingforums.com/member.php?u=5798[/url]"}; [small](Edited by [url=http://www.ozoneasylum.com/user/5032]liorean[/url] on 03-22-2006 13:50)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »