On Mon, 07 Feb 2005 14:50:51 -0500, JDS <jeffrey@go.away.com> wrote:
[color=blue]
>Hi, all. I'd like to do the following, preferably *without* resorting to
>javascript
:
>
>I have a long, dynamically-generated form questionnaire. Not all of the
>form fields are dynamically generated, though.
>
>I'd like to capture the NAME of every HTML form field element on the
>server, even if that element is submitted blank. The trouble is, with,
>say, radio buttons or checkboxes for example, a *blank* element does not
>get submitted at all.[/color]
This behaviour is required by the HTML standard:
http://www.w3.org/TR/html401/interac...html#h-17.13.2 http://www.w3.org/TR/html401/interact/forms.html#radio
[color=blue]
>Example:
><form action="text.php">
><input type="radio" name="firstbutton" value="1">
><input type="radio" name="firstbutton" value="2">
><input type="radio" name="firstbutton" value="2">
><input type="text" name="thetextbox">
></form>
>
>If the form is submitted completely blank, text.php prints out:
>
>Array
>(
> [thetextbox] =>
>)
>
>ONLY if I click a value on one of the radio buttons do I get the field
>"firstbutton", e.g.:
>
>Array
>(
> [thetextbox] =>
> [firstbutton] => 1
>)
>
>How can I get the names of all of the fields in the HTML form even if they
>are sent blank? I am considering using JavaScript onSubmit() to put fake
>values in for blank fields, but using JS is not desirable. I had been
>putting hidden fields in with the field name "field_names[nameoffield]"
>for each form field but this does not scale well for any non-dynamic form
>fields.[/color]
Adding extra elements is AFAIK the only method, given that HTML requires that
non-selected radio buttons are not successful.
--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool