Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Form action= ?

Reply
Thread Tools

Form action= ?

 
 
shajnday
Guest
Posts: n/a
 
      08-13-2010
What would form action do?

I had an html tag <form><input .... without the requested atributes
action (and .ev.method="").
This tag is working fine but due to restrictions of XHTML transitional
validation i had to change it to <form action="#"><input..... />
</form>

and it works as it worked before, but now it passes HTML validation.

What is the best to put at action="" atribute and method and what's
the puropeses of these two atributes ?
i don't get the purpose part. ?



 
Reply With Quote
 
 
 
 
Denis McMahon
Guest
Posts: n/a
 
      08-13-2010
On 13/08/10 12:38, shajnday wrote:
> What would form action do?
>
> I had an html tag <form><input .... without the requested atributes
> action (and .ev.method="").
> This tag is working fine but due to restrictions of XHTML transitional
> validation i had to change it to <form action="#"><input..... />
> </form>
>
> and it works as it worked before, but now it passes HTML validation.
>
> What is the best to put at action="" atribute and method and what's
> the puropeses of these two atributes ?
> i don't get the purpose part. ?


If your form doesn't have an action (ie it's just a wrapper for input /
textarea / select elements) then why are you using form? You can
dispense with it, as the following shows (validates as direct input with
a charset warning).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
<script type="text/javascript">
function clicked(obj)
{
alert(obj.name + " " + obj.id + " " + obj.value);
}
</script>
</head>
<body>
<p>
<input type="text" name="t1" id="t1" size="30"><br>
<select name="s1" id="s1">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select><br>
<textarea name="a1" id="a1" rows="5" cols="80"></textarea><br>
<input type="button" id="b1" name="b1" value="Reset"
onclick="clicked(this)">
<input type="button" id="b2" name="b2" value="Submit"
onclick="clicked(this)">
</p>
</body>
</html>

If you want input / reset buttons with onclicks to drive your
javascript, just use normal buttons with the values set to "Reset" and /
or "Submit" and use their onclick handlers instead. If you're using the
form name to refer to elements, switch to document.getElementById().

Rgds

Denis McMahon
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-13-2010
Denis McMahon wrote:
> If your form doesn't have an action (ie it's just a wrapper for input /
> textarea / select elements) then why are you using form? You can
> dispense with it, as the following shows (validates as direct input with
> a charset warning).


Well not necessarily, it all depends on that the OP is doing with these
controls.

If all you are doing using controls to interact with some JavaScript,
then yes you can dispense with the form element. But if the OP intends
to submit data either via GET or POST then:

A form element *is* required
The the controls must be inside form element
The controls must have name attributes
The form must have a valid action attribute

See <www.w3.org/TR/html401/interact/forms.html#successful-controls>

Browsers will summit a form to the URI of the current document if the
action attribute is not default, but they are not obligated to because
the condition is "undefined" See that action is a required
attribute with a valid URI else the condition is "undefined" under
"Attribute Definitions"

<http://www.w3.org/TR/html401/interact/forms.html#edef-FORM>


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Denis McMahon
Guest
Posts: n/a
 
      08-13-2010
On 13/08/10 18:51, Jonathan N. Little wrote:
> Denis McMahon wrote:


> If all you are doing using controls to interact with some JavaScript,
> then yes you can dispense with the form element. But if the OP intends
> to submit data either via GET or POST then:


The whole point of the OPs post, as I understood it, was to find some
pseudo-value to use for the action field so that the html would
validate, that kind of suggests to me that he's not actually submitting
the form.

Because if he was actually submitting the form, I'd expect him to have a
real action value and not need some pseudo-value to get the page to
validate.

Rgds

Denis McMahon
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      08-13-2010
In article <4c658c88$0$10277$>,
Denis McMahon <> wrote:

> On 13/08/10 18:51, Jonathan N. Little wrote:
> > Denis McMahon wrote:

>
> > If all you are doing using controls to interact with some JavaScript,
> > then yes you can dispense with the form element. But if the OP intends
> > to submit data either via GET or POST then:

>
> The whole point of the OPs post, as I understood it, was to find some
> pseudo-value to use for the action field so that the html would
> validate, that kind of suggests to me that he's not actually submitting
> the form.
>


Possibly, but he might be just testing or making a template and
feels uncomfortable with it lazily lying about invalid.


> Because if he was actually submitting the form, I'd expect him to have a
> real action value and not need some pseudo-value to get the page to
> validate.
>


--
dorayme
 
Reply With Quote
 
William Gill
Guest
Posts: n/a
 
      08-13-2010
On 8/13/2010 2:18 PM, Denis McMahon wrote:
> The whole point of the OPs post, as I understood it, was to find some
> pseudo-value to use for the action field so that the html would
> validate, that kind of suggests to me that he's not actually submitting
> the form.


I suspect the OP, and many others have a misconception of what exactly
validation is.

I'm sure Yucca will correct me if I misstate it, but validation checks
that a document conforms precisely to the structure defined by a
particular DTD. Much like a spell checker validates that words in a
document conform to a particular dictionary. So if I use a term that
means something to an audience, but not necessarily to the dictionary
(i.e. fubar = f'ed up beyond all recognition), the spell checker will
point out the "validation error." At that point I can add fubar to the
dictionary, or recognize the "error" is deliberate and ignore it.
Similarly, when validating against a particular DTD, and I get a
validation error that was deliberate, I can ignore it or create a
modified version of the DTD that matches the variation. The inherent
risk is that if I leave the "error" in the document, then ask an
application (i.e. a browser) that relies on the original DTD (or even my
modified version) to parse the document I don't know how it will react
to the non-conforming entry, and how it reacts today may not be how it
will react after the next update.

The value of validation is finding all the unintentional deviations.

 
Reply With Quote
 
shajnday
Guest
Posts: n/a
 
      08-14-2010
On 14 kol, 01:23, William Gill <nos...@domain.invalid> wrote:
> On 8/13/2010 2:18 PM, Denis McMahon wrote:
>
> > The whole point of the OPs post, as I understood it, was to find some
> > pseudo-value to use for the action field so that the html would
> > validate, that kind of suggests to me that he's not actually submitting
> > the form.

>
> I suspect the OP, and many others have a misconception of what exactly
> validation is.
>
> I'm sure Yucca will correct me if I misstate it, but validation checks
> that a document conforms precisely to the structure defined by a
> particular DTD. *Much like a spell checker validates that words in a
> document conform to a particular dictionary. *So if I use a term that
> means something to an audience, but not necessarily to the dictionary
> (i.e. fubar = f'ed up beyond all recognition), the spell checker will
> point out the "validation error." *At that point I can add fubar to the
> dictionary, or recognize the "error" is deliberate and ignore it.
> Similarly, when validating against a particular DTD, and I get a
> validation error that was deliberate, I can ignore it or create a
> modified version of the DTD that matches the variation. *The inherent
> risk is that if I leave the "error" in the document, then ask an
> application (i.e. a browser) that relies on the original DTD (or even my
> modified version) to parse the document I don't know how it will react
> to the non-conforming entry, and how it reacts today may not be how it
> will react after the next update.
>
> The value of validation is finding all the unintentional deviations.




I have put astray the form element as i have thought that it is the
necessary block element in which goes input...
As i had thought that the form element is a process element of some
kind and that it does some important actions so as when submitting
button to print or to close a page. I checked(what previously did not
came to my mind) and left only the input element and it works the
same. Validation shows pass!

One another thing was strange which made me to leave the form element
at first, when i submited the close button i sometimes got the "Are
you sure you want to close this window?"question, for which i had
thoughts that is the action of form element.

I don't receive this question anymore, i think it's a browser inner
action at some point to trigger it...

 
Reply With Quote
 
shajnday
Guest
Posts: n/a
 
      08-14-2010
On 14 kol, 21:01, shajnday <catal...@dr.com> wrote:
> On 14 kol, 01:23, William Gill <nos...@domain.invalid> wrote:
>
>
>
>
>
> > On 8/13/2010 2:18 PM, Denis McMahon wrote:

>
> > > The whole point of the OPs post, as I understood it, was to find some
> > > pseudo-value to use for the action field so that the html would
> > > validate, that kind of suggests to me that he's not actually submitting
> > > the form.

>
> > I suspect the OP, and many others have a misconception of what exactly
> > validation is.

>
> > I'm sure Yucca will correct me if I misstate it, but validation checks
> > that a document conforms precisely to the structure defined by a
> > particular DTD. Â*Much like a spell checker validates that words in a
> > document conform to a particular dictionary. Â*So if I use a term that
> > means something to an audience, but not necessarily to the dictionary
> > (i.e. fubar = f'ed up beyond all recognition), the spell checker will
> > point out the "validation error." Â*At that point I can add fubar to the
> > dictionary, or recognize the "error" is deliberate and ignore it.
> > Similarly, when validating against a particular DTD, and I get a
> > validation error that was deliberate, I can ignore it or create a
> > modified version of the DTD that matches the variation. Â*The inherent
> > risk is that if I leave the "error" in the document, then ask an
> > application (i.e. a browser) that relies on the original DTD (or even my
> > modified version) to parse the document I don't know how it will react
> > to the non-conforming entry, and how it reacts today may not be how it
> > will react after the next update.

>
> > The value of validation is finding all the unintentional deviations.

>
> I have put astray the form element as i have thought that it is the
> necessary block element in which goes input...
> As i had thought that the form element is a process element of some
> kind and that it does some important actions so as when submitting
> button to print or to close a page. I checked(what previously did not
> came to my mind) and left only the input element and it works the
> same. Validation shows pass!
>
> One another thing was strange which made me to leave the form element
> at first, when i submited the close button i sometimes got the "Are
> you sure you want to close this window?"question, for which i had
> thoughts that is the action of form element.
>
> I don't receive this question anymore, i think it's a browser inner
> action at some point to trigger it...- Sakrij citirani tekst -
>
> - Prikaži citirani tekst -



Yeah,
Thanks for that mr.Gill,
I did learned that.
I do have a lot of warnings but the page is fully functional in three
most exposed browsers and it is showed the very same, and i'am happy
about that. Not that i don't like validation buttons as they do look
great on the page, but it's only an aestehetic appendix.
As the knowledge tree is growing so i make valuations what is worth to
leave, and what is worth to rewrite or fix. Sometimes things jump from
byitself in front of me but i enjoy in it, everything is cheerful and
fun at my place.
Thanks for precious advice though.
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      08-14-2010
William Gill wrote:

> Similarly, when validating against a particular DTD, and I get a
> validation error that was deliberate, I can ignore it or create a
> modified version of the DTD that matches the variation.


Indeed. But many people want to validate due to some external requirement.
They don't understand the reasons for the requirement (maybe there isn't
one), and they don't even understand the content of the requirement; they
just want to "pass validation", or get a "clean report".

If the requirement really means that you must "validate against HTML 4.01",
then you just cannot have a <form> element without an action attribute. You
can use a fake value there (since validation does not check the attribute
value at all, except for some minor formalities), or you can dispense with a
<form> element if your form fields are purely JavaScript-driven (and then
you have an accessibility issue, but that's a completely different
perspective).

> The inherent
> risk is that if I leave the "error" in the document, then ask an
> application (i.e. a browser) that relies on the original DTD (or even
> my modified version) to parse the document I don't know how it will
> react to the non-conforming entry,


Theoretically yes, but in practice, browsers don't use DTDs. Some browsers
have validation add-ons, but they don't affect the rendering.

The risk is that you are using an element, or an attribute, or a syntax of
an element that won't be supported by all browsers. People say that HTML
4.01 DTDs reflect the constructs that browsers actually support, but this is
just partly true. There are HTML 4.01 features that aren't supported at all,
or aren't supported by very commonly used browsers. And there are features
that are virtually universally supported but not part of HTML 4.01.

> The value of validation is finding all the unintentional deviations.


Right - it is meant to protect against typos and similar mistakes.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
William Gill
Guest
Posts: n/a
 
      08-15-2010
On 8/14/2010 3:38 PM, Jukka K. Korpela wrote:
>
> Indeed. But many people want to validate due to some external
> requirement. They don't understand the reasons for the requirement
> (maybe there isn't one), and they don't even understand the content of
> the requirement; they just want to "pass validation", or get a "clean
> report".


As I have observed many times over the years "There is no reason. It's
just policy."

Most likely someone implemented the requirement as a metric, without
understanding any of the implications. Similar to "lines of code per
day" as a metric for programmers.

> Theoretically yes, but in practice, browsers don't use DTDs. Some
> browsers have validation add-ons, but they don't affect the rendering.


I didn't really expect that browsers used DTDs in real time, but I would
guess that programmers use them when they are designing the code, even
if not when the code is run.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve form field value if form is EncType=multipart/form-dataForm? Li Zhang ASP .Net 4 02-27-2009 01:23 AM
<form>...</form> - how to supress blank space after </form> in IE? rob c Javascript 4 12-30-2005 01:18 PM
vs2005 - Open a child form based on selected record parent form's dgv - how? dbuchanan ASP .Net 2 12-19-2005 10:52 PM
Form in a form - possible ? Adam Benson ASP .Net 3 07-29-2003 09:19 AM
passing arguments from web-form to win-form Mart Rogers ASP .Net 3 07-09-2003 07:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57