Re: Keeping form fields populated

From: Date: Thu, 15 May 2003 20:07:05 +0000
Subject: Re: Keeping form fields populated
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147787@lists.php.net to get a copy of this message
On 15 May 2003, Brian V Bonini wrote: >On Thu, 2003-05-15 at 14:28, Steve Keller wrote: >I see what your saying but how would you handle say a group of radio >buttons and reselecting what was previously selected? Get creative. :) Some people do it with Perl regexes via preg_replace on a variable holding all your inputs. Like, the equivalent of what is in Perl: s/value="$example"/value="$example" checked="checked"/; Which in PHP is: preg_replace("/value=\"$example\"/", "/value=\"$example\" checked=\"checked\"/", $inputs); Another thing you can do is for an input like this: <input type="radio" name="example" value="one" /> <input type="radio" name="example" value="two" /> <input type="radio" name="example" value="three" /> You can do something like: <? $checked[$example] = ' checked="checked"'; ?> <input type="radio" name="example" value="one"<? print $checked["one"]; ?> /> <input type="radio" name="example" value="two"<? print $checked["two"]; ?> /> <input type="radio" name="example" value="three"<? print $checked["three"]; ?> /> You can even automate that with a foreach loop on a predefined array of the options available, if it works in your setup. Best wishes, Jw. -- John C Worsley | Lead Programmer / Web Developer, Command Prompt, Inc. (503) 222-2783 | jlx@commandprompt.com | webmaster@thelinuxreview.com TheLinuxReview | News for Linux Users | http://www.thelinuxreview.com

« previous php.general (#147787) next »