[thelist] retaining values in forms while alerting use mistakes

Mark Joslyn Mark.Joslyn at SolimarSystems.com
Mon Jul 9 12:36:41 CDT 2007

For checkboxes and combo boxes, I create an array ($key=>$value) and when
displaying, I just loop through each value like this:

$myArray = array("Prod1" => "Item One Name", etc...);

foreach ($myArray as $key=>$value) {
	if ($_POST[$data] == $value {
		echo "<option value=\"" . $key . "\" selected=\"selected\">"
. $value . "</option>\n";
	} else {
		echo "<option value=\"" . $key . "\">" . $value .

When the form builds, each item will loop through and compare itself with
the posted values.

I have also found that checkboxes will return "on" when checked, and not the
values you place in the <input> tag. If you handle checkboxes as an array,
like name="Checks[]", then the value you specify can be returned.

Hope that helps.


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Nan Harbison
Sent: Monday, July 09, 2007 10:16 AM
To: thelist at lists.evolt.org
Subject: [thelist] retaining values in forms while alerting use mistakes

I have googled myself silly, and have tried a bunch of ways to maintain the
values of checkboxes and drop down boxes when the user makes a mistake. Of
course, text boxes are easy.
I thought I found two simple solutions, but I am putting either a comment or
a php statement within a form element tag, and I get the right side of the
tag (>) showing next to the check box or to the left of the text in the drop
down boxes.
You can see this here:
I tried putting a web comment in such as <!--{monthselected1}--> and
replacing this with 'selected' if the user has chosen this month.
I have tried :
<?PHP if (isset $HTTP_POST_VARS[monthselected1] {echo  $monthselected1; } ?>

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 

More information about the thelist mailing list