|
|
|
<?php
////////////////////////////////////////////////////////////
// PopUpMenu 0.5
// make a popup menu that maintains its state
//
// Paul Schreiber
// paul@magic.ca
// http://paulschreiber.com/
//
// parameters
// ----------
//
// name: the name attribute you want for the <SELECT> tag
//
// values: a hash that contains the values and labels for
// the <OPTION> tags
//
// javascript: javascript for the <SELECT> tag, i.e.
// onChange="this.form.submit()" [optional]
//
// size: the SIZE attribute for the <SELECT> tag [optional]
//
//
//
if ( !defined('POPUP_MENU_DEFINED') ) {
define('POPUP_MENU_DEFINED', TRUE);
function popup_menu ($name, $values, $javascript = "", $size = 1) {
// grab this to maintain state
global $$name;
$selected = ($$name) ? $$name : "";
// start building the popup meny
$result = "<select name=\"$name\"";
if ($size != 1)
$result .= " size=\"$size\"";
if ($javascript)
$result .= " " . $javascript;
$result .= ">\n";
$result .= "<option value=\"\">\n";
// list all the options
while ( list( $value, $label ) = each( $values ) ) {
// printed SELECTED if an item was previously selected
// so we maintain the state
if ($selected == $value) {
$result .= "<option value=\"$value\" SELECTED>$label\n";
} else {
$result .= "<option value=\"$value\">$label\n";
}
}
// finish the popup menu
$result .= "</select>\n";
echo $result;
}
}
?> |
|
| A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | Display Slashdot headers on your own site Categories : HTML and PHP, HTML, PHP | | | webcam cam view image ispy browser independant Categories : Graphics, HTML, HTML and PHP, PHP | | | How to preset a text string in a textarea input field Categories : HTML, HTML and PHP, PHP, Beginner Guides | | | Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but
effective. Categories : PHP, PHP Classes, HTML, HTML and PHP | | | This script shows you the 7th latest php items from the mailing list archive on zend.com Categories : HTML, HTML and PHP, HTTP, PHP | | | GonxTabs : Create elegant HTML tabs based interface Categories : Navigation, HTML, HTML and PHP, PHP | | | class formHTML build your HTML Forms from PHP Categories : PHP, PHP Classes, HTML and PHP, HTML | | | Snipe.Net's Web Design Color Scheme Previewer- Allows uses to input hex
codes for their text, background, and link colors, and preview the color
scheme with their background image. Example:
http://www.snipe.net/tech/snipeschool/hex.php3 Categories : PHP, HTML and PHP, General, Graphics, HTML | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to use regular expressions to get the list of links from an HTML page Categories : PHP, Regexps, HTML, HTML and PHP | | | Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance. Categories : HTML, PHP, HTML and PHP, Beginner Guides | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Calendar using Date function Categories : HTML and PHP, PHP, Date Time, Calendar | | | phpCards - PHP/mySQL postcard script with web based admin to add, edit, and delete cards and categories. Very easy to install. Categories : PHP, Complete Programs, HTML and PHP, MySQL | |
|
|
|