jbrugger has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I try to convert my application (that uses CGI) and HTML::Template from a html generating app to an xhtml generating application.
the html 'name' isn't allowed anymore, all has to be done using 'id', but if i submit a form, CGI expects the form elements to have names, thus the form seems empty using id only.
Am i missing something here, or is the id of a form element just not been read yet by CGI?

ps. the xhtml has to validate against the w3c validator. (using strict in stead of transitional)
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

Replies are listed 'Best First'.
Re: cgi-bin and xhtml
by gellyfish (Monsignor) on Mar 22, 2005 at 15:15 UTC

    I think you are confusing internal fragment identifiers which must indeed be set with the id attribute with the perfectly legitimate name attribute on the <input> element - please see the XHTML DTD if you need confirmation of this.

    /J\

      Is it? <form action="/cgi-bin/script.pl..." method="post" name="LoginForm"> is not Valid XHTML 1.0 Strict
      I use multiple forms, where i have checked the name of a submitted form to perform an certin action (and the elements in the different forms might even be the same)
      update
      But indeed, name for an input type works fine.
      "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

        That's the form name, which is only used by client side script (i.e. it is never used by server side script). That should be an id (which can them be referenced by JavaScript in the document.forms collection just like the old name attribute).

        It is form controls (like input, select and textarea) that need names. (Its also a good idea to give them ids so you can reference them with label elements, but the ids and names do not have to be the same.)

        Er, I don't see anywhere I mention the <form> element - I refer explicitly to the <input> element.

        /J\