By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

<form> GETting to an #anchor

P: n/a
Hi,

I'm trying to write a <form> whihc will retrieve a Web page on another
server. I have (essentially) this:

<form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi">
<input type="submit"><select name="N">
<option value="1234#1234-01">foo
<option value="1010#1010-02">bar
<option value="1001#1001-03">baz
</select></form>

The point is that submitting the form will lead the reader to
(respectively)
http://cgi.cs.indiana.edu/~oracle/di...N=1234#1234-01
http://cgi.cs.indiana.edu/~oracle/di...N=1010#1010-02 or
http://cgi.cs.indiana.edu/~oracle/di...N=1001#1001-03

but it doesn't work that way. Instead, the '#' in the <option value> gets
URL encoded. So is there some other way to cause a form to GET to an
anchor on a page?

Tia,

Michael Hamm Since mid-September of 2003,
AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
ms****@math.wustl.edu Of a reply, then, if you have been cheated,
http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Mon, 22 Dec 2003 15:37:30 -0600, Michael Hamm declared in
comp.infosystems.www.authoring.html:
I'm trying to write a <form> whihc will retrieve a Web page on another
server. I have (essentially) this:

<form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi">
<input type="submit"><select name="N">
<option value="1234#1234-01">foo
<option value="1010#1010-02">bar
<option value="1001#1001-03">baz
</select></form>


What's wrong with normal links?

<a
href="http://cgi.cs.indiana.edu/~oracle/digest.cgi?N=1234#1234-01">foo</a><
br>
<a
href="http://cgi.cs.indiana.edu/~oracle/digest.cgi?N=1010#1010-02">bar</a><
br>
<a
href="http://cgi.cs.indiana.edu/~oracle/digest.cgi?N=1001#1001-03">baz</a><
br>

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 20 '05 #2

P: n/a
Michael Hamm <ms****@math.wustl.edu> wrote:
I have (essentially) this:

<form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi">
<input type="submit"><select name="N">
<option value="1234#1234-01">foo
<option value="1010#1010-02">bar
<option value="1001#1001-03">baz
</select></form>
The order is somewhat odd, since the choice is made before the
submission. Besides, if this is the whole story, then links would work
better, as Mark Parnell pointed out.
The point is that submitting the form will lead the reader to
(respectively)
http://cgi.cs.indiana.edu/~oracle/di...N=1234#1234-01
http://cgi.cs.indiana.edu/~oracle/di...N=1010#1010-02 or
http://cgi.cs.indiana.edu/~oracle/di...N=1001#1001-03
It won't, because there's no way to add a fragment identifier into the
URL that a GET submission generates. The generated URL consists of the
action URL followed by a question mark and the form's data set in a
particular format, and there's no provision for including a fragment.
(If the action URL contained a fragment, a malformed URL would be
generated, since a fragment, if present, must appear last, by URL
syntax.)
but it doesn't work that way. Instead, the '#' in the <option
value> gets URL encoded.
That's right, and how things are defined.
So is there some other way to cause a
form to GET to an anchor on a page?


You could set up a very simple "intermediator" script that takes the
input from your form and constructs a URL, with a fragment, and
redirects to it. You can then hope that a browser interprets this the
way you want - effectively storing the fragment, sending a request for
the redirect URL, and then positioning the document received, as
specified by the fragment.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #3

P: n/a
On Tue, 23 Dec 2003 00:29:13 +0000 (UTC), Jukka K. Korpela
<jk******@cs.tut.fi> wrote, in part:
I have (essentially) this:

<form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi">
<input type="submit"><select name="N">
<option value="1234#1234-01">foo
<option value="1010#1010-02">bar
<option value="1001#1001-03">baz
</select></form>
The order is somewhat odd, since the choice is made before the
submission.


Yeah, but I think that people are both (a) used to such things and (b)
intelligent enough to figure it out even if unused to such things.
Besides, if this is the whole story, then links would work better, as
Mark Parnell pointed out.
Well, the list is somewhat longer, and takes up too much room on the page
for my liking in this instance.
there's no way to add a fragment identifier into the URL that a GET
submission generates.


Thanks fyi.
So is there some other way to cause a
form to GET to an anchor on a page?


You could set up a very simple "intermediator" script that takes the
input from your form and constructs a URL, with a fragment, and
redirects to it.


Thanks fyi.

Michael Hamm Since mid-September of 2003,
AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
ms****@math.wustl.edu Of a reply, then, if you have been cheated,
http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
Jul 20 '05 #4

P: n/a
mh***@artsci.wustl.edu (Michael Hamm) wrote:
The order is somewhat odd, since the choice is made before the
submission.
Yeah, but I think that people are both (a) used to such things and
(b) intelligent enough to figure it out even if unused to such
things.


Regarding (a), I don't think such a wrong order is common. Regarding
(b), intelligence does not help if you are blind, for example. After
some failed attempts, the user might figure out what's going on - and
ask himself why the author did something that annoying.
Well, the list is somewhat longer, and takes up too much room on
the page for my liking in this instance.


This is the common "space saving" issue. You save space - the reusable
screen real estate, that is - at the cost of creating accessibility and
usability impediments. For example, how do you open a page in a new
window according to your (i.e., user's) choice when <select> is used?
Right, you don't. Links Want To Be Links, for more than a dozen
reasons, see http://www.cs.tut.fi/~jkorpela/www/links.html

Besides, if you insist on "saving space" - as if it would be a save if
you don't let the user see all the options at a glance when possible -
then using CSS to make a list occupy a "fixed" height (say height:10em)
and to make the content scrollable (overflow: scroll) is a better
approach. It would let links be links.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #5

P: n/a
On Tue, 23 Dec 2003 13:58:24 +0000 (UTC), Jukka K. Korpela
<jk******@cs.tut.fi> wrote, in part:
Well, the list is somewhat longer, and takes up too much room on
the page for my liking in this instance.
<snip> using CSS to make a list occupy a "fixed" height (say height:10em)
and to make the content scrollable (overflow: scroll) is a better
approach.


Ah, thanks, good idea.

Happy holidays,

Michael Hamm Since mid-September of 2003,
AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
ms****@math.wustl.edu Of a reply, then, if you have been cheated,
http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
Jul 20 '05 #6

P: n/a
On Tue, 23 Dec 2003 13:58:24 +0000 (UTC), Jukka K. Korpela
<jk******@cs.tut.fi> wrote, in part:
Well, the list is somewhat longer, and takes up too much room on
the page for my liking in this instance.
<snip> Besides, if you insist on "saving space" - as if it would be a save if
you don't let the user see all the options at a glance when possible -
then using CSS to make a list occupy a "fixed" height


Another idea (which will work because the text within my list items is
very short, as in the example I posted): I'll use <dir> (in HTML4
Transitional, or <ol class="dir"> in Strict) with
dir{display:block}dir li{display:inline}
dir li + li:before{content:", "}

Then, of course, the problem is whether browsers will display it
correctly. But I suspect the newer ones will. Probably the worst that
would happen would be that a comma would be displayed before the first
item, or no comma would be displayed between any two items -- not the end
of the world in either case.

Michael Hamm Since mid-September of 2003,
AM, Math, Wash. U. St. Louis I've been erasing too much UBE.
ms****@math.wustl.edu Of a reply, then, if you have been cheated,
http://math.wustl.edu/~msh210/ Likely your mail's by mistake been deleted.
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.