Re: HTML_Select

From: Date: Sat, 12 Oct 2002 16:20:35 +0000
Subject: Re: HTML_Select
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-10037@lists.php.net to get a copy of this message
+1 for that - it's something I've needed lots of times, and to have it built in to PEAR would be a Good Thing. Also, my idea on updating the country codes, is to make regular releases of the package, with an updated list of country codes/names - although someone may be able to come up with something that'll take less effort. Jon ----- Original Message ----- From: "Richard Heyes" <richard@phpguru.org> To: "PEAR Dev" <pear-dev@lists.php.net> Sent: Sunday, October 13, 2002 2:14 PM Subject: [PEAR-DEV] HTML_Select > Hi, > > Been playing around making some common select dropdown code and came up with > the following > package idea: > > HTML > | > +-Select > | > +-Country.php > +-USStates.php > +-UKCounties.php > > Some sample code for the country script: > > require_once('I18N/Country.php'); > > class HTML_Select_Country extends I18N_Country > { > function getDropDown($name, $selectedOption = null) > { > $options[] = '<option value="">Select a > country...</option>'; > $selectedOption = strtolower($selectedOption); > > foreach ($this->_codes as $code => $country) { > $code = strtolower($code); > $selected = $selectedOption == $code ? ' selected="selected"' : > ''; > $options[] = '<option value="' . $code . '"' . > $selected . '>' . > ucfirst(strtolower($country)) . '</option>'; > } > > return sprintf('<select name="%s">%s</select>', $name, > implode("\r\n", $options)); > } > } > > Thoughts ? > > -- > Richard Heyes > V-webmail - http://www.v-webmail.co.uk > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pear.dev (#10037) next »