WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Popup Menu 0.5, popup, select, html, state-maintaing
Categories : HTML, PHP, HTML and PHP Update Picture
Paul Schreiber
Date : Aug 04th 1999
Grade : 2 of 5 (graded 4 times)
Viewed : 8851
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Paul Schreiber
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?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