HTML_Select

From: Date: Sun, 13 Oct 2002 13:14:42 +0000
Subject: HTML_Select
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-10032@lists.php.net to get a copy of this message
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

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