|
Posted by Tim Streater on 07/07/07 21:35
In article <cpQji.188188$Az6.160054@reader1.news.saunalahti.fi>,
"Jukka K. Korpela" <jkorpela@cs.tut.fi> wrote:
> Scripsit Tim Streater:
>
> >> Both action and method are required attributes.
> >
> > Hmm, I understood action to be optional.
>
> There's some confusion here. In a <form> element, the method="..." attribute
> is and always was optional, with the default value being "GET". The
> action="..." attribute is required, and it has been required ever since HTML
> 4.0.
>
> > And that without it, the
> > default action was that the same form reloaded.
>
> Well, the same _page_. In HTML 3.2, the action="..." attribute was optional,
> with the default value being the URL of the page on which the form appears.
> Browsers might still behave that way, but it's not a good idea to use
> invalid markup and to rely on behavior that is holdover from some previous
> version.
Right. If that's invalid then I'll certainly add it.
> > Additionally, I could
> > well want to go to different places depending on the button pushed or
> > the data that the form passes off to some Javascript.
>
> You might want that, but can you do that reliably?
>
> > I don't want to
> > show an action that will never be taken - that just confuses whoever
> > follows me on the code. I could imagine something like <form
> > action="none" ... > to make this explicit but can;t recall ever having
> > seen such an option.
>
> There is no such option. By HTML versions from HTML 4.0 onwards, the meaning
> of a form element is undefined unless it has an action attribute with a http
> URL.
OK.
> If a form exists only for the purpose of JavaScript-based interaction, then
> the form, and perhaps the entire page, should be JavaScript-generated so
> that it does not appear when it does not work. Even then, a conforming
> action="..." attribute _is_ useful. It's a sentinel against errors that may
> arise when the form is, after all, used in a browser where scripting is not
> enabled. (For example, a page might be generated by JavaScript code but the
> user might then disable scripting. To take a less far-fetched example, an
> author might just goof things up and e.g. omit the JavaScript code that
> prevents normal form submission.)
>
> The sentinel attribute could be action="error.html" where error.html is a
> document that explains that an unexpected error occurred. You might write a
> longer explanation if you like, but most users probably wouldn't understand
> it. What matters is that users are informed about an error, instead of just
> weird behavior or everything going well on the surface while everything is
> broken.
Well, I can tell them to contact me, although they know to do that
anyway. The user base is our engineers, our NOC's engineers, and some of
our customers' engineers. They all know who I am.
> > Yes, I see that - but I did try to emphasise that I had cut down the
> > example to the minimum required to demonstrate my problem. I have
> > seen, in other groups, people post 1000 lines of code and ask why it
> > doesn't work,
>
> Posting a URL is still the best approach in HTML problems. If you don't have
> a URL, create one. It doesn't take that long to compose a valid document and
> upload it on a server.
Right, I'll bear that in mind.
[Back to original message]
|