Question : Is it possible to tell it to use unique variables (preferrable some auto-incrementing index, but will take all solutions).
I could be wrong, but AFAIK, in HTML, a <select> element with the
"multiple" attribute will always submit one variable per selected
option.
For example, selecting three items will produce something like:
language=javascript&language=php&language=python
<select name="language[]" multiple>
This tells the browser to submit all selected values as elements of
an array.
Most server-side languages will automatically treat this as an array.
HTML itself cannot auto-increment variable names
I could be wrong though,
I could be wrong though,
Yeah, you could be.
[Arlen wrote]:
Is there any other way it can be done than ?
<select name="language[]" multiple>Thats bullcrap. They will still be just names, but now width some brackets added. And those are meaningless to the browser (the program that is emitting them).
This tells the browser to submit all selected values as elements of
an array.
And pray tell, why would a server-side language *parsing the URI* need those brackets at the end of the name, and not simply on a second same name (without any kind of brackets) recognise it should than (obviously) be put into an array ? iow, its doesn't need those brackets.
And if you don't parse them but just feed them to an "eval()" than you're opening a humongous security hole.
Besides, some languages use round brackets for arrays, an others use curly-brackets. And though I can't remember, I'm sure some languages use pointy brackets.
HTML itself cannot auto-increment variable names
Well, than its good that its *the browser* which combines all the names and their values into a query string and attaches it to the outgoing request, isn't it ?
Most server-side languages will automatically treat this as an array.
Hi Gondolfo,
No problem. I provided the answer that most web developers would give.
a. A <select multiple> always submits repeated names
b. name="language[]" is a widely used and valid convention
Maybe try:
comp.infosystems.www.authoring.stylesheets comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.cgi
Is there any other way it can be done than ?
Generate your HTML with a check box per language?
Concur that browser side it's the same. Some URL parsing tools,
like PHP, will not treat them as the same however.
There's no way for the interpretation agnostic system to know if
it should be interpreted as "later value overrides earlier" (such
as some command line tools will behave) or "later value supplements
earlier".
And if you don't parse them but just feed them to an "eval()"
than you're opening a humongous security hole.
If you feed any part of the URL line to eval(), I have to wonder
WTF you are doing.
Consult your URL parsing library's documentation and see what
hinting is correct. The Common Gateway Inteface (RFC 3875) does
not provide any URL parsing direction. Just pass the whole thing
unmodified to the script.
Having the same name appear multiple times was explicitly allowed
by the original forms spec:
...Maybe try:
comp.infosystems.www.authoring.cgi
Eli,
Maybe try:
comp.infosystems.www.authoring.stylesheets comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.cgi
Thanks. I'm not sure how authoring.stylesheets or authoring.CGI are relevant to my question, but perhaps authoring.html is the newsgroup that will know.
But, no idea how to get that SELECT list to play nice ? Either by auto-incrementing the name for each selected item, or using the name in each OPTION ? Shucks.
AFAIK the parsing of the URL is done *before* PHP (or any other language in its place) is called. The called program (PHP or something else) just gets its arguments thru its commandline or in its environment.
True, but its rather common behaviour. Especially when arguments are passed by way of environment variables.
Hence my question how to get unique names from a html SELECT element.
So every kind of (scripting) language that gets the honor to do some work for the HTTP server needs to know everything about how to handle URI's ?
Also, how does that work when you upload a file ? :-)
My current question focusses on the client side. If I can get that side to emit unique variable names I do not need to bother with handling non-unique variable names at server side.
But as that doesn't seem part of what the webbrowser can do for me I should perhaps ask that authoring.cgi newsgroup how non-unique variable names should be/are normally handled server-side (iow, a belated thanks for mentioning that newsgroup).
comp.infosystems.www.authoring.cgi
I noticed your followup that states you don't have that third one. I
have was subscribed once, but am not now, so if was rmgrouped I would not noticed.
The CSS group has the most traffic (not much), and CSS is used
for things that used to be the domain of javascript once, hence
the suggestion
But, no idea how to get that SELECT list to play nice ? Either
by auto-incrementing the name for each selected item, or using
the name in each OPTION ? Shucks.
The SELECT is playing by the rules that have existed since Mosaic
was the headline browser. Just because you don't like those rules,
doesn't mean it's not nice.
You are wrong. PHP gets the full query string
The environment variable the web server sends looks like
QUERY_STRING=name=value&name=content&name=stuff&text=foo
Hence my question how to get unique names from a html SELECT
element.
You seem to misunderstand. Query strings were a bolt-on to the
original HTTP protocol and were never really for HTTP servers
to handle.
You are wrong. PHP gets the full query string
Nope. You forgot the word "also". PHP *also* gets the full *query*
string - as a result of the HTTP server having put it into an environment variable before calling the program/script to handle the request.
Just think of how a file-upload would work if PHP would be doing all the heavy lifting. No, what PHP (or any other program/script in its place) gets is all pre-chewed.
The environment variable the web server sends looks like
QUERY_STRING=name=value&name=content&name=stuff&text=fooYes, exactly. The *web server* - or rather: the HTTP server - puts the raw query string into the environment of the script/program it calls to handle the request.
At that point the HTTP server has also added slew of other environment variables, including the ones with the names and values of the variables in the URI it received.
But, as having the webbrowser modify those names to make them unique (or allowing me to provide unique names in the OPTION elements themselves) does not seem to exist, I'll have to rewrite that part of my http server to handle them instead.
There are a slew of variables, but there is not a parsed query
string. PHP does the parsing. It searches for the separator and the
equals sign itself, and decides if something should be treated as a
regular variable or an array based on finding square brackets.
PHP does do all the "heavy lifting" for file uploads.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 59 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 18:03:59 |
| Calls: | 810 |
| Calls today: | 1 |
| Files: | 1,287 |
| D/L today: |
10 files (21,017K bytes) |
| Messages: | 193,396 |