473,586 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

empty form actions

Say I have the following HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<form action="">
</form>
</body>

It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption? Is a
standards-compliant browser guaranteed to see empty action attributes
as being self-referential actions?

Sep 5 '06 #1
8 4775
yawnmoth wrote:
Say I have the following HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<form action="">
</form>
</body>

It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption? Is a
standards-compliant browser guaranteed to see empty action attributes
as being self-referential actions?
yawnmoth,

No guarantee at all. What the HTML Recommendation says is "User agent
behavior for a value other than an HTTP URI is undefined.".

See http://www.w3.org/TR/html401/interac...ml#adef-action

Chris Beall
Sep 5 '06 #2
yawnmoth wrote:

<form action="">
It seems to validate ok and my tests suggest that when the action
attribute is blank, that the action will be assumed to be the current
location, but is this a reasonable assumption?
I'm given to understand that the URL spec resolves that as the current
URL ... but I've seen browsers treat it as "./", so I'd avoid it.
--
David Dorward <http://blog.dorward.me .uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 5 '06 #3
Chris Beall wrote:
yawnmoth wrote:
[snip]
>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?
Guaranteed? I wouldn't like to say. It certainly should though as that
is how empty URI references are defined.

<aside>
One thing I'm curious about is why IE resolves such URIs correctly for
action attributes, but not anchor href attributes. Perhaps it was one of
those things that Microsoft intentionally broke.
</>
No guarantee at all. What the HTML Recommendation says is "User agent
behavior for a value other than an HTTP URI is undefined.".
Yes, so specifying a URI that uses a ftp or mailto scheme, for example,
leads to undefined behaviour.

Relative URIs are permitted and a relative URI always uses the same
scheme. Therefore an empty URI reference (which is a relative URI) is
also permitted.

[snip]

Mike
Sep 6 '06 #4
Michael Winter wrote:
Chris Beall wrote:
>yawnmoth wrote:

[snip]
>>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?

Guaranteed? I wouldn't like to say. It certainly should though as that
is how empty URI references are defined.
Looking to refute this, I found that you're correct, which tells me,
unless I'm missing something *now*, that I and others have been giving
incorrect information here.

From RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt):

4.2. Same-document References

A URI reference that does not contain a URI is a reference to the
current document. In other words, an empty URI reference within a
document is interpreted as a reference to the start of that document,
and a reference containing only a fragment identifier is a reference
to the identified fragment of that document. Traversal of such a
reference should not result in an additional retrieval action.
However, if the URI reference occurs in a context that is always
intended to result in a new request, as in the case of HTML's FORM
element, then an empty URI reference represents the base URI of the
current document and should be replaced by that URI when transformed
into a request.
>
<aside>
One thing I'm curious about is why IE resolves such URIs correctly for
action attributes, but not anchor href attributes. Perhaps it was one of
those things that Microsoft intentionally broke.
IE is definitely wrong. Firefox reloads the current page (including the
original query string!), which the spec passage above says it shouldn't do.

On form submission with the POST method, both browsers conform to the
passage above, even to the extent of including any query string from the
original request. With GET, the form data replaces, rather than being
appended to, the original query string.
Sep 6 '06 #5
Harlan Messinger wrote:
Michael Winter wrote:
>>yawnmoth wrote:
>>>Is a standards-compliant browser guaranteed to see empty action
attributes as being self-referential actions?

Guaranteed? I wouldn't like to say. It certainly should though as
that is how empty URI references are defined.

Looking to refute this, I found that you're correct ...
Always nice to know. :-)

Simple evidence can be found in the reference resolution examples (5.4
in RFC 3986, Appendix C in RFC 2396):

Within a representation with a well defined base URI of

http://a/b/c/d;p?q

a relative reference is transformed to its target URI as
follows.

....

"" = "http://a/b/c/d;p?q"
which tells me, unless I'm missing something *now*, that I and others
have been giving incorrect information here.
Really? Obviously I haven't read every post on the subject sent to this
group, but I've never noticed bad advice (and if I had, I'd have
mentioned it). Still, you've drawn attention to something that I've
overlooked in the past.
From RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt):
By the way, 2396 has been obsoleted by 3986 (the latter being a
standard: STD 66).

[snip]
>One thing I'm curious about is why IE resolves such URIs correctly
for action attributes, but not anchor href attributes. Perhaps it
was one of those things that Microsoft intentionally broke.

IE is definitely wrong.
There was no doubt in my mind about that! It resolves such a URI as if
it were ".".
Firefox reloads the current page (including the original query
string!),
The original query string is to be expected as both the path /and/ the
query string identify a particular resource, so a same-document
reference must include both...
which the spec passage above says it shouldn't do.
....but I had overlooked the part about not re-retrieving the current
document. That said, the URI specifications do not seem to reference or
use RFC 2119 (requirements levels), and even if they did, it would be a
SHOULD, not MUST, requirement.

In this instance, I think there is justification for overriding any such
desire to prevent new requests as a user agent cannot know, just from
the URI alone, whether a new request is actually warranted. After all,
using the example from the RFC, even a URI "d;p?q" would be considered a
same-document reference as it resolves to the base URI. To force a
reload using only a link, one would have to add (and constantly alter)
the query string, or use client-side scripting (not that the latter
would be sensible).

If the desire is to eliminate a new request, then HTTP already provides
a feature capable of that very thing: caching.
On form submission ... With GET, the form data replaces, rather than
being appended to, the original query string.
Yes, I've found that to be annoying and, in my opinion, quite stupid.
Why force authors to include hidden form controls to pass on operational
parameters rather than just using the query string?

Mike
Sep 6 '06 #6
Michael Winter wrote:
Harlan Messinger wrote:
>Firefox reloads the current page (including the original query
string!),

The original query string is to be expected as both the path /and/ the
query string identify a particular resource, so a same-document
reference must include both...
Right, I didn't indicate that I understood this to be correct. It was
more like I was *marveling* that both browsers got that right.
>
>which the spec passage above says it shouldn't do.

...but I had overlooked the part about not re-retrieving the current
document. That said, the URI specifications do not seem to reference or
use RFC 2119 (requirements levels), and even if they did, it would be a
SHOULD, not MUST, requirement.

In this instance, I think there is justification for overriding any such
desire to prevent new requests as a user agent cannot know, just from
the URI alone, whether a new request is actually warranted. After all,
using the example from the RFC, even a URI "d;p?q" would be considered a
same-document reference as it resolves to the base URI. To force a
reload using only a link, one would have to add (and constantly alter)
the query string, or use client-side scripting (not that the latter
would be sensible).
AFAIK, all the browsers know not to reload the page when an HREF points
to an anchor on the current page, regardless of the URI form used in the
HREF (whether http://www.example.com/x#hello, /x#hello, or #hello).
>
If the desire is to eliminate a new request, then HTTP already provides
a feature capable of that very thing: caching.
>On form submission ... With GET, the form data replaces, rather than
being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite stupid.
Why force authors to include hidden form controls to pass on operational
parameters rather than just using the query string?
Ah, but: if the form appears on the page in response to every submission
of the form by the user, then on the second submission the form's data
will be appended to the existing query string--which already includes
the data from the first form submission. This would likely break
whatever the page was supposed to be doing with the data.
Sep 6 '06 #7
Harlan Messinger wrote:

[snip]
AFAIK, all the browsers know not to reload the page when an HREF
points to an anchor on the current page, regardless of the URI form
used in the HREF (whether http://www.example.com/x#hello, /x#hello,
or #hello).
For fragments, certainly, but they're a special case. The URI
specification refers to all same-document references, as far as I can see.

[snip]
>>On form submission ... With GET, the form data replaces, rather
than being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite
stupid. Why force authors to include hidden form controls to pass
on operational parameters rather than just using the query string?

Ah, but: if the form appears on the page in response to every
submission of the form by the user, then on the second submission the
form's data will be appended to the existing query string--which
already includes the data from the first form submission. This would
likely break whatever the page was supposed to be doing with the
data.
I don't think I made myself clear. Consider:

<form action="?stage= 1" method="get">
<!-- ... -->
<input name="foo" value="bar">
<!-- ... -->

with a base URI of:

http://www.example.com/processor

When submitted, the URI will be

http://www.example.com/processor?foo=bar

not

http://www.example.com/processor?stage=1&foo=bar

I would expect the document URI to be completely replaced, but I don't
see why the query string needs to be stripped from the action attribute
value.

By comparison, making a POST request will use a request URI of:

http://www.example.com/processor?stage=1

In either case, if the form needed to be resubmitted, the action
attribute would still be the same as before, and the new form data would
be sent in addition to that pre-set value. The previously sent data
would not be involved.

Is that a better explanation? I think you thought that I meant that with
a /base/ URI of:

http://www.example.com/processor?name=value

I'd want the URI to be:

http://www.example.com/processor?name=value&foo=bar

or something like that, which isn't the case.

Mike
Sep 6 '06 #8
Michael Winter wrote:
Harlan Messinger wrote:

[snip]
>AFAIK, all the browsers know not to reload the page when an HREF
points to an anchor on the current page, regardless of the URI form
used in the HREF (whether http://www.example.com/x#hello, /x#hello,
or #hello).

For fragments, certainly, but they're a special case. The URI
specification refers to all same-document references, as far as I can see.

[snip]
>>>On form submission ... With GET, the form data replaces, rather
than being appended to, the original query string.

Yes, I've found that to be annoying and, in my opinion, quite
stupid. Why force authors to include hidden form controls to pass
on operational parameters rather than just using the query string?

Ah, but: if the form appears on the page in response to every
submission of the form by the user, then on the second submission the
form's data will be appended to the existing query string--which
already includes the data from the first form submission. This would
likely break whatever the page was supposed to be doing with the
data.

I don't think I made myself clear. Consider:

<form action="?stage= 1" method="get">
<!-- ... -->
<input name="foo" value="bar">
<!-- ... -->

with a base URI of:

http://www.example.com/processor

When submitted, the URI will be

http://www.example.com/processor?foo=bar

not

http://www.example.com/processor?stage=1&foo=bar

I would expect the document URI to be completely replaced, but I don't
see why the query string needs to be stripped from the action attribute
value.

By comparison, making a POST request will use a request URI of:

http://www.example.com/processor?stage=1

In either case, if the form needed to be resubmitted, the action
attribute would still be the same as before, and the new form data would
be sent in addition to that pre-set value. The previously sent data
would not be involved.

Is that a better explanation?
Much more clear, thanks.

Sep 7 '06 #9

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

Similar topics

4
2289
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
3
7870
by: Christopher Mocock | last post by:
Hi all, Bit of a python newbie so need a little help with a CGI script I'm trying to write. I've got it working fine as long as the fields of the form are filled in correctly, however I need to be able to accept blank entries. Therefore I want to convert any empty entries to an empty string. For example, if I call the following CGI script...
4
1522
by: Peter Bremer | last post by:
Hi all, I've got a form which lists all members of a club, with checkboxes to select them. The form offers functions to delete selected members, send email, etc. Now I want write some code to perform complex analyses on the selected members. I'd prefer to keep this code seperated from the basic form processing, opening a new page with...
6
2917
by: Ryan Liu | last post by:
Hi, I have a form, with some user control in it, usually hung up when I call form.Show(). I debug to there, I found in Visual Studio 2003, the call stack is empty! And CPU is not busy at all. Can anyonoe give me idea about what is happening?
6
1541
by: Asle | last post by:
Hi, i am using ms access 2000. I have 3 tables called tblJob, tblPrint, tblDesign with one-to-one relationship. I haved divided into different tables since i dont want to have too many fields in a single table. tbljob: JobID - PK PrintID - FK1
26
3883
by: pepper.gabriela | last post by:
Hello, a stupid question but... page_A.php is a page with a form. The user inserts text in four fields, then he clicks a submit button. The data goes to page_B.php: this page controls the data submitted, then echoes a message. If there were problems with the submitted data the message says: "a problem occurred with your data. Click here to...
11
3429
by: iReachable | last post by:
Hi! We are seeeing many users with XP experiencing empty form data issue. Browwer = Explorer 7.0, OS = Windows Vista Browser = Firefox 2.0.0, OS = Windows XP Browser = Explorer 6.0, OS = Windows XP Browser = Firefox 1.0.7, OS = Windows XP Broswer = Opera 9.25, OS = Windows XP
10
2223
flexsingh
by: flexsingh | last post by:
Hello there, I have a form and when data is inputted it goes into the table and I can get it out pefectly fine, the problem I have is that if the promary key is empty it will not submit, but if any of the other fields are empty except the primary key then the forms submits. Is there a way to stop the form submitting unless all the fields are...
3
1853
by: swethak | last post by:
Hi, I am getting the problem with form tag. i,e in in form action i am placing the some autoresponder page like <form name="form1" method="post" action="http://www.autoresponder.com"> When i submit this form it goes to the page http://www.autoresponder.com .Along with this i want to run some extra functionality(mail sending)...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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...
0
8200
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. ...
1
5710
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...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
0
1179
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...

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.