J
JDS
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.
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>
text.php
<?php
print_r($_REQUEST);
?>
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.
Any other ideas?
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.
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>
text.php
<?php
print_r($_REQUEST);
?>
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.
Any other ideas?