|
Posted by Oberon on 08/24/07 03:36
Understood.
However, I have done this before using
$_POST['<--hardCodedValueGoesHere-->'] = NULL;. I was wondering if there
was a way to accomplish this with a loop structure instead of longhand,
line-by-line for each form value....particularly if I have a form with 30+
fields which I am required to build.
Currently this is the test form:
*****************************************************
<form name="dataPlayground" method="post" action="<?php
$_SERVER['PHP_SELF']; ?>">
<p>
<label for="textfield">First Name:</label>
<br>
<input name="firstName" type="text" class="inputCSS" value="<?php echo
$_POST['firstName']; ?>" id="firstName">
</p>
<p>
<label for="label">Middle Name:</label>
<br>
<input name="middleName" type="text" class="inputCSS" value="<?php echo
$_POST['middleName'] ?>" id="label">
</p>
<p>
<label for="label2">Last Name:</label>
<br>
<input name="lastName" type="text" class="inputCSS" value="<?php echo
$_POST['lastName'] ?>" id="label2"></p>
<p>
<label for="Submit"></label>
<input type="submit" name="mojo" value="Submit Me" id="Submit">
<label for="label3"></label>
<input type="reset" name="Submit2" value="Reset" id="label3">
</p>
</form>
*****************************************************
The reason I want to do what I want to do is two-fold:
1. Preserve entered data in the fields in case the form is not properly
filled out.
2. Use an array structure for error checking and changing the CSS
properties to visually indicate an error on the page.
--Like I said, I've done this before, I'm just looking for a short form way
to do it.
Thanks,
Rob
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:c9SdnUknBuwr31PbnZ2dnUVZ_jednZ2d@comcast.com...
> Oberon wrote:
>> I am looking to initialize form values to NULL prior to the client
>> filling in the form.
>>
>> I would like to do this using an array by putting all of the form
>> variables into it and setting them using a foreach() loop to NULL.
>>
>> Is there a way to do this using PHP 5.1.2?
>
> HTML does not recognize null values. A form object always has a value,
> although that value may be an empty string.
>
> Some types of form objects (i.e. checkboxes) will only send their value of
> they are checked. Others (i.e. text fields) will send an empty string if
> there is nothing in the field.
>
> PHP cannot change this behavior.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================
Navigation:
[Reply to this message]
|