Hello Everyone, Thanks for all the suggestions on my sticky form problem. I've changed my action attribute to empty "" as per the article on PHP_SELF. I'm still having an issue getting the form to redisplay. For example, if i don't fill out the name field how would i get the form to redisplay with all the rest of the entered values? I've got text values working, but combo boxes are not. I've got three values i'll take the type one here, one is zero and it's choice is to select an option. That's a required field, so if it's skipped zero is given, I want to indicate that's not valid and redisplay the form. Event is 1 and meeting is 2 or maybe i've got those reversed but it doesn't matter. So, say I select 2 for meeting or event or whatever, but again i don't fill in the name field. I want the form to redisplay, but to have the combo box values filled in. I'm certain this is conceptual and coding on my part, I'd appreciate any assistance. Thanks. Dave. On 7/4/10, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx> wrote: > On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote: > >> Hello, >> I've got a form with several required fields of different types. I >> want to have the php script process it only when all the required >> fields are present, and to redisplay the form with filled in values on >> failure so the user won't have to fill out the whole thing again. >> One of my required fields is a text input field called name. If it's >> not filled out the form displayed will show this: >> >> <input type="text" name="name" id="name" size="50" value="<?php >> echo($name); ?>" /> <br /> >> >> Note, I've got $_POST* variable processing before this so am assigning >> that processing to short variables. >> If that field is filled out, but another required one is not that form >> field will fill in the value entered for the name field. >> This is working for my text input fields, but not for either select >> boxes or textareas. Here's the textarea also a required field: >> >> <textarea name="description" id="description" cols="50" rows="10" >> value="<?php echo($description); ?>"></textarea> > > Textarea fields don't work this way. To display the prior value, you > have to do this: > > <textarea name="description><?php echo $description; ?></textarea> > >> >> What this does, if a user fills out this field, but misses another, it >> should echo the value of what was originally submitted. It is not >> doing this. Same for my select boxes, here's one: >> >> <select name="type" id="type" value="<?php echo($type); ?>"> >> <option value="0" selected="selected">-- select type --</option> >> <option value="meeting"> - Meeting - </option> >> <option value="event"> - Event - </option> >> </select> > > The "value" attribute of a select field won't do this for you. You have > to actually set up each option with an either/or choice, like this: > > <option value="0" <?php if ($type == 'meeting') echo 'selected="selected"'; > ?>> - Meeting - </option> > > Since doing this is pretty tedious, I use a function here instead: > > function set_selected($fieldname, $value) > { > if ($_POST[$fieldname] == $value) > echo 'selected="selected"'; > } > > And then > > <option value="meeting" <?php set_selected('type', 'meeting'); > ?>>Meeting</option> > > HTH, > > Paul > > -- > Paul M. Foster > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php