RE: HTML_Select

From: Date: Tue, 15 Oct 2002 14:21:02 +0000
Subject: RE: HTML_Select
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-10058@lists.php.net to get a copy of this message
Good idea. However, I would like there to be a method: HTML_Select->setChooseText("Choose:"); with the default being what you have "Choose a country:" Actually, I would like to see part of the eXtremePHP library implemented here. You can view the library at http://www.extremephp.org every HTML tag is extended from HtmlTag, which has the methods addParameter(name, value) and setParameter(name, value) ... set changes the current parameter. Having a base class is very handy for all sorts of HTML objects. Not you would make every html code in your page with the library, but I can see it handy for pre-built objects such as select lists, menus, etc. > -----Original Message----- > From: Richard Heyes [SMTP:richard@phpguru.org] > Sent: Sunday, October 13, 2002 8:15 AM > To: PEAR Dev > Subject: 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 >

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