Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Same named input elements in different forms?

0 views
Skip to first unread message

Ed Jay

unread,
Dec 28, 2009, 11:50:15 AM12/28/09
to
Is it allowable to use the same name for multiple input elements if
they're in different forms? Example:

<form name = 'form1' .... >
<input name= 'field1' ... >
</form>

<form name = 'form2' .... >
<input name= 'field1' ... >
</form>

--
Ed Jay (remove 'M' to reply by email)

Win the War Against Breast Cancer.
Knowing the facts could save your life.
http://www.breastthermography.info

Harlan Messinger

unread,
Dec 28, 2009, 12:22:29 PM12/28/09
to
Ed Jay wrote:
> Is it allowable to use the same name for multiple input elements if
> they're in different forms? Example:
>
> <form name = 'form1' .... >
> <input name= 'field1' ... >
> </form>
>
> <form name = 'form2' .... >
> <input name= 'field1' ... >
> </form>
>

Yes.

Ed Jay

unread,
Dec 28, 2009, 12:32:21 PM12/28/09
to
Harlan Messinger wrote:

Thanks.

dorayme

unread,
Dec 28, 2009, 4:19:13 PM12/28/09
to
In article <vsqhj5hvks0oogqvr...@4ax.com>,
Ed Jay <ed...@aes-intl.com> wrote:

> Harlan Messinger wrote:
>
> >Ed Jay wrote:
> >> Is it allowable to use the same name for multiple input elements if
> >> they're in different forms? Example:
> >>
> >> <form name = 'form1' .... >
> >> <input name= 'field1' ... >
> >> </form>
> >>
> >> <form name = 'form2' .... >
> >> <input name= 'field1' ... >
> >> </form>
> >>
> >
> >Yes.
>
> Thanks.

Just a minute! Is this thread some sort of joke? A bloke asks a clear
question, another answers simply, the first thanks him and that's it? No
complications, no misunderstandings, no personal animosity, no
irrelevant posts thrown into the mix?

I don't like it! It is too good, there must be something wrong. Whenever
my old Ford ran too well, it was a bad sign.

--
dorayme

Jukka K. Korpela

unread,
Dec 28, 2009, 4:25:14 PM12/28/09
to
dorayme wrote:

> Just a minute! Is this thread some sort of joke?

Maybe.

> No complications, no misunderstandings, no personal animosity, no
> irrelevant posts thrown into the mix?

You just proved that to be wrong.

(And we don't know what the real problem was, as usual.)

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

Beauregard T. Shagnasty

unread,
Dec 28, 2009, 5:00:29 PM12/28/09
to
Ed Jay wrote:

> Is it allowable to use the same name for multiple input elements if
> they're in different forms?

Probably. Possibly. But since they are in different forms, why do you
want to muddy the waters over in your (unnamed) action script?

$field1 = $_POST['field1'];

Umm, which one? Think about maintenance in six months...

--
-bts
-tossing 2� more, 'cause I can

Sherm Pendley

unread,
Dec 28, 2009, 5:07:12 PM12/28/09
to
dorayme <dorayme...@optusnet.com.au> writes:

> In article <vsqhj5hvks0oogqvr...@4ax.com>,
> Ed Jay <ed...@aes-intl.com> wrote:
>
>> Harlan Messinger wrote:
>>
>> >Ed Jay wrote:
>> >> Is it allowable to use the same name for multiple input elements if
>> >> they're in different forms? Example:
>> >

>> >Yes.
>>
>> Thanks.
>
> Just a minute! Is this thread some sort of joke? A bloke asks a clear
> question, another answers simply, the first thanks him and that's it?

Yeah, well, it's the holidays. ;-)

sherm--

dorayme

unread,
Dec 28, 2009, 5:16:43 PM12/28/09
to
In article <kn9_m.56846$La7....@uutiset.elisa.fi>,

"Jukka K. Korpela" <jkor...@cs.tut.fi> wrote:

> dorayme wrote:
>
> > Just a minute! Is this thread some sort of joke?
>
> Maybe.
>
> > No complications, no misunderstandings, no personal animosity, no
> > irrelevant posts thrown into the mix?
>
> You just proved that to be wrong.
>
> (And we don't know what the real problem was, as usual.)

I started to have misgivings about my light-hearedness the moment I
pressed the send button. <g>

--
dorayme

Doug Miller

unread,
Dec 28, 2009, 5:18:56 PM12/28/09
to
In article <hhb9pt$ola$1...@news.eternal-september.org>, a.non...@example.invalid wrote:
>Ed Jay wrote:
>
>> Is it allowable to use the same name for multiple input elements if
>> they're in different forms?
>
>Probably. Possibly. But since they are in different forms, why do you
>want to muddy the waters over in your (unnamed) action script?
>
>$field1 = $_POST['field1'];
>
>Umm, which one? Think about maintenance in six months...
>
Since they are in different forms, there's no reason to suppose that the same
script processes each form.

Beauregard T. Shagnasty

unread,
Dec 28, 2009, 5:23:52 PM12/28/09
to
Doug Miller wrote:

> a.non...@example.invalid wrote:
>> Ed Jay wrote:
>>> Is it allowable to use the same name for multiple input elements if
>>> they're in different forms?
>>
>> Probably. Possibly. But since they are in different forms, why do
>> you want to muddy the waters over in your (unnamed) action script?
>>
>> $field1 = $_POST['field1'];
>>
>> Umm, which one? Think about maintenance in six months...
>>
> Since they are in different forms, there's no reason to suppose that
> the same script processes each form.

..further muddying the waters.

--
-bts
-Four wheels carry the body; two wheels move the soul

Harlan Messinger

unread,
Dec 28, 2009, 5:56:03 PM12/28/09
to
Beauregard T. Shagnasty wrote:
> Ed Jay wrote:
>
>> Is it allowable to use the same name for multiple input elements if
>> they're in different forms?
>
> Probably. Possibly. But since they are in different forms, why do you
> want to muddy the waters over in your (unnamed) action script?
>
> $field1 = $_POST['field1'];
>
> Umm, which one? Think about maintenance in six months...
>

If the forms are submitted to different URLs, it doesn't matter. If they
are submitted to the same URL, then either the forms are meant to serve
as alternate interfaces to the same handler, in which case they are
*supposed* to be indistinguishable, or they aren't, in which case it's
hard to imagine that the developer hasn't figured out that they two
forms need to be routed somehow to two different handlers.

Ed Jay

unread,
Dec 28, 2009, 6:27:35 PM12/28/09
to
Harlan Messinger wrote:

I'll answer everyone's response with this...

I have two forms contained on the same page. A credit memo form and a
debit memo form. The visible form depends on the user's menu choice. Each
form contains a single checkbox element, which when checked, is the flag
to send the memo to the recipient of the credit or debit when whichever
form is submitted.

I thought of the complexity of sorting things out at my Perl script end,
and decided it would be much easier if I could simply use two input
elements with the same name in each of the two forms. All my script does
is if the box is checked, do a routine. No chance for conflicts, but I
appreciate the concern for potential problems. That's why, when I was
unsure, I thought of asking.

So, I asked my question, with enough information given to solicit a simple
yes/no answer. Harlan's answer was spot on, and appropriately commented on
by dorayme.

Thanks to all.

Jukka K. Korpela

unread,
Dec 29, 2009, 1:15:16 PM12/29/09
to
Ed Jay wrote:

> I'll answer everyone's response with this...

As usual, the situation would have been much clearer if you had posted the
URL, and the URL would still be useful.

> I have two forms contained on the same page. A credit memo form and a
> debit memo form.

That's possible, but why not put them on separate pages? What are the odds
that both of them are needed at the same time?

> The visible form depends on the user's menu choice.

Do you mean that you rely on CSS _and_ scripting to make one of the forms
invisible? In effect, you have one form per page, but you do that in an
unnecessarily complicated and unreliable way.

> Each form contains a single checkbox element, which when checked, is
> the flag to send the memo to the recipient of the credit or debit
> when whichever form is submitted.

I don't quite see why you need it, but presumably sending the memo is an
optional feature in form data processing.

> I thought of the complexity of sorting things out at my Perl script
> end, and decided it would be much easier if I could simply use two
> input elements with the same name in each of the two forms.

I can't believe it can be "much easier" - you would probably need just one
conditional expression.

You _can_ use the same name="..." attribute, of course (though not the same
id="..." attribute). And there's no particular reason to use different
attributes. The same applies to the approach of using two separate pages, as
you would probably generate them by the same Perl script, just with some
parameterization.

> So, I asked my question, with enough information given to solicit a
> simple yes/no answer.

And the correct answer was given, but the question was wrong, in practical
terms. Well, rather irrelevant, let us say. The question you now implicitly
(well, very implicitly...) asked is much more important: should you have two
forms on the same page?

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

0 new messages