473,780 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What happens if several text fields have the same name?

Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?

Jul 24 '05 #1
17 16186


wo******@yahoo. com wrote:
Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?


When form data is submitted name=value pairs are submitted so on the
server you can't tell from the submitted data whether it comes from
input type="text" or input type="checkbox" controls.
As for processing the submitted form data on the server that depends on
the framework/language used on the server, if you use ASP/VBScript then
you can use a for each loop e.g.

For Each Value In Request.Form("i nputName")
Response.Write Value & "<br>"
Next

If it is not ASP you are using then ask in an appropriate group on the
server side framework/language you are using. For further ASP questions
you could use the ASP groups on nsnews.microsof t.com.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 24 '05 #2
Tim
On 24 May 2005 09:00:50 -0700,
wo******@yahoo. com posted:
Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?


This sounds like a JavaScript issue, not HTML (how you're going about using
forms), but you don't really say what you're doing and how, and it sounds
like you might be using forms incorrectly.

For things like radio or select form elements, where you're using
multiple-choices for any one particular answer (whether allowing multiple
answers out of the choices - checkboxes, or only one answer out of all of
the choices - radio buttons), all the *associated* input elements have to
use the same name. And conversely, any disassociated input elements must
use different names.

e.g.

<fieldset>
<legend>Gende r</legend>
<label><input type="radio" name="sex" value="female"> female</label><br>
<label><input type="radio" name="sex" value="male"> male</label><br>
<label><input type="radio" name="sex" value="other"> other</label>
</fieldset>

<fieldset>
<legend>Likes these pets</legend>
<label><input type="checkbox" name="pets" value="cats"> cats</label><br>
<label><input type="checkbox" name="pets" value="dogs"> dogs</label><br>
<label><input type="checkbox" name="pets" value="fish"> fish</label>
</fieldset>

But, for things like text input elements, they're all individual,
stand-alone, data entry gadgets, and each must use their own names.

e.g.

<fieldset>
<legend>Your names</legend>
<label>First name: <input type="text" name="firstname "></label><br>
<label>Surnam e: <input type="text" name="lastname" ></label>
</fieldset>

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
Jul 24 '05 #3
Tim wrote:
On 24 May 2005 09:00:50 -0700,
wo******@yahoo. com posted:

Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?

This sounds like a JavaScript issue, not HTML (how you're going about using
forms), but you don't really say what you're doing and how, and it sounds
like you might be using forms incorrectly.

For things like radio or select form elements, where you're using
multiple-choices for any one particular answer (whether allowing multiple
answers out of the choices - checkboxes, or only one answer out of all of
the choices - radio buttons), all the *associated* input elements have to
use the same name. And conversely, any disassociated input elements must
use different names.

e.g.

<fieldset>
<legend>Gende r</legend>
<label><input type="radio" name="sex" value="female"> female</label><br>
<label><input type="radio" name="sex" value="male"> male</label><br>
<label><input type="radio" name="sex" value="other"> other</label>
</fieldset>

<fieldset>
<legend>Likes these pets</legend>
<label><input type="checkbox" name="pets" value="cats"> cats</label><br>
<label><input type="checkbox" name="pets" value="dogs"> dogs</label><br>
<label><input type="checkbox" name="pets" value="fish"> fish</label>
</fieldset>

But, for things like text input elements, they're all individual,
stand-alone, data entry gadgets, and each must use their own names.


Reference? I don't think they have to, and it works just fine. In ASP,
you get an array of values, whether it's with SELECT options,
checkboxes, or text fields.
Jul 24 '05 #4
Gazing into my crystal ball I observed wo******@yahoo. com writing in
news:11******** **************@ g44g2000cwa.goo glegroups.com:
Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?


That should still work. I am assuming you are using ASP. What is the
value of request.form("n ame") if you do response.write "Name: " &
request.form("n ame")?

This is really a server side issue, and should be directed to a server
side group. If you are using ASP, I would suggest you take this to
microsoft.publi c.inetserver.as p.general .

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Jul 24 '05 #5
wo******@yahoo. com wrote:
Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("n ame") and
maybe do a split(request.f orm("name"),"," ) to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.

My experience is that you get the contents of the text box that is last
defined with a given name. None of the others show up.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 24 '05 #6
On Tue, 24 May 2005, Jim Moe wrote:
My experience is that you get the contents of the text box that is last
defined with a given name. None of the others show up.


Then you have an incomplete server-side implementation, but this
is off-topic for the HTML authoring group.

The HTML spec specifies the format of the submitted dataset (as sent
from the client to the server). That part is on-topic here.

The interface between the server and your server-side process depends
a bit on what it is (CGI, ASP, PHP, whatever), but the most portable
interface is defined by the CGI, which is now an informational RFC
http://www.ietf.org/rfc/rfc3875 , and would be on-topic in
comp.infosystem s.www.authoring.cgi (beware the automoderation bot).

Any complete implementation should give you access to multiple values
from "form control(s)"[1] with the same name.

At this point in the procedure the server neither knows nor cares what
kind of form control that was. They could easily be of different
kinds (e.g a pull-down list and a type-in text box of the same name)
if you wanted. Or not, as you choose.

have fun

[1] using that term as it's used in the html4 spec.
Jul 24 '05 #7
Zif
Harlan Messinger wrote:
Tim wrote:

[...]
But, for things like text input elements, they're all individual,
stand-alone, data entry gadgets, and each must use their own names.

Reference? I don't think they have to, and it works just fine. In ASP,
you get an array of values, whether it's with SELECT options,
checkboxes, or text fields.


Regardless of what happens on the server, what is served to the client
should be consistent with the DOCTYPE supplied with the document.

Presuming that HTML is being served, an input name must be unique
within a form unless it is a checkbox or a radio button. From memory,
IE allows the creation of a collection using identical names on any
element, however that is not consistent with the W3C HTML 4
Specification.

<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-INPUT>

<URL:http://www.w3.org/TR/html4/interact/forms.html#inpu t-control-types>

Most browsers will cope with invalid HTML, however that does not make
its use valid or reasonable.

If the intention is to group a bunch of elements visually, then
FIELDSET is the logical choice:

<URL:http://www.w3.org/TR/html4/interact/forms.html#edef-FIELDSET>

If the intention is to create a group of elements that can be accessed
purely by script, 'DIV' or 'SPAN' may do the job. As a last resort,
the 'class' attribute may fit the bill.
--
Zif
Jul 24 '05 #8
Alan J. Flavell wrote:
On Tue, 24 May 2005, Jim Moe wrote:

My experience is that you get the contents of the text box that is last
defined with a given name. None of the others show up.

Then you have an incomplete server-side implementation, but this
is off-topic for the HTML authoring group.


I disagree with that. If the OP is serving invalid HTML that has INPUT
text elements with duplicate names, browser behaviour is not defined
and you can't be certain of what will be returned to the server.

In that context, it is very much a HTML issue.

The HTML spec specifies the format of the submitted dataset (as sent
from the client to the server). That part is on-topic here.
And what the server sends to the client is irrelevant? The server needs
to start out by sending valid HTML (or whatever is specified in the
DOCTYPE), otherwise you are just guessing at what the UA may do.

[...] At this point in the procedure the server neither knows nor cares what
kind of form control that was. They could easily be of different
kinds (e.g a pull-down list and a type-in text box of the same name)
if you wanted. Or not, as you choose.
If that was to occur in the same form, then that is invalid HTML and UA
behaviour may not be what you expect.
have fun

[1] using that term as it's used in the html4 spec.

--
Rob
Jul 24 '05 #9
On Wed, 25 May 2005, Zif wrote:
Presuming that HTML is being served, an input name must be unique
within a form unless it is a checkbox or a radio button.
Citation, please? I don't find any such text in the HTML4 spec.
From memory,
There's no extra charge for checking before posting.
IE allows the creation of a collection using identical names on any
element,
As do the WWW-compatible browsers that I tried, indeed.
however that is not consistent with the W3C HTML 4 Specification.
I'll reserve judgment on that till we've found the relevant text in
the HTML4 spec. The use of the same name on radio buttons and
checkboxes has a defined effect as laid down in the HTML4 spec, yes,
but I find nothing which prohibits the use of the same name on mixed
control types. I certainly don't find the text which you're claiming
to have remembered.
<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-INPUT>

<URL:http://www.w3.org/TR/html4/interact/forms.html#inpu t-control-types>
Not there either...
Most browsers will cope with invalid HTML, however that does not
make its use valid


Which validator and which DTD did you use, and where's your
demonstration document? Mine (using name=, not id=) passed without
errors. Trying to use the same id=, even on two radio buttons, or two
checkboxes, *will* fail HTML validation, in spite of your claim, but
that's a general HTML rule, it isn't specific to forms.

And don't forget select multiple: that too can submit several values
with the same name, although in this case you'd normally have just one
"control" with the name in question.

thanks
Jul 24 '05 #10

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

Similar topics

10
3728
by: ross | last post by:
I want to do some tricky text file manipulation on many files, but have only a little programming knowledge. What are the ideal languages for the following examples? 1. Starting from a certain folder, look in the subfolders for all filenames matching *FOOD*.txt Any files matching in each folder should be copied to a new subfolder within the current folder called EATING with a new name of *FOOD*COPY.txt
3
1546
by: P.Hill | last post by:
I have this simple bit of code that when you check a checkbox and it displays or hides two other fields (well actually two parts of the document with two different IDs. Pretty straight forward... I thought. The fields come and go, but something happens to the table formatting; on NS 7.1 and Firefox 1.0 it seems to miscount or hide the number of TD tags or something else confusing. Can anyone tell me what I'm doing wrong? -Paul
6
6186
by: Iver Erling Årva | last post by:
I am looking for a way to let the users copy e.g. a multi-line address from a textfile and paste it into a webpage where there is one input field for each address line in such a way that not only the first line is pasted, but instead the program automatically jumps to the next field and put line 2 in there and so on. Can this be done? I tried with onkeydown to check for event.keyCode == 13, but it doesn't seem to work with paste. Brgds
1
1761
by: Mad Scientist Jr | last post by:
I have a textbox control (for simplicity call it Text1) with autopostback turned on. It has a couple validators: RequiredFieldValidator_Text1 RegularExpressionValidator_Text1 The Text1 onchange (see code below) event does these things 1. fires the validators
3
1549
by: Terry Olsen | last post by:
I've got 2 different web pages, both updating the same SQL database. One is for the Technician and one is for the Manager. The technician's update page works fine but the Manager's update page doesn't. They are both the same..as far as I can tell... --------------------- This code works fine, updating the SQL database with the edited data. Code for Tech Page
8
2495
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript" type="text/javascript"> <!-- ; var newwindow = ''
5
5916
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and these fields are not unique in the respective tables. Like CompanyID, MemberID
4
1922
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this post. Basically, this will work correctly if I remove all non-form related tags from the form =eg span, div, but I want to format the form all pretty like so??? Right now, it only collects 2 parts of the form fields =sites &
1
1492
by: John Dalberg | last post by:
What causes a server event to fire when something happens on the client? Say a user changed the gridview's page index, the server side PageIndexChanged event is fires. What makes PageIndexChanged fires? Is it a field in the viewstate? Is it a value in the forms collections? I am trying to understand the mechanism of communication between the browser and the server. John Dalberg
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.