Php > Miscellaneous
Make select menu that remembers users choice
Make select menu that remembers users choice $text) { $selected = ($chosen == $option) ? ' selected="selected"' : ''; $list .= "
$text
\n"; } return "\n
\n$list
\n"; } // example usage session_start(); // here we define the option names, and the corresponding text to be displayed for that option // for example
I like Red
$options = array( 'red' => 'I like Red', 'blue' => 'I like Blue', 'green' => 'I like Green' ); // this will be the
I like Red
I like Blue
I like Green
and if the user selects "green", this would be the output
I like Red
I like Blue
I like Green
HERES HOW SMALL THE CODE IS w/out comments: $options = array( '' => 'Choose Your Favorite Color', 'red' => 'I like Red', 'blue' => 'I like Blue', 'green' => 'I like Green' ); $menuName = 'favoriteColor'; $chosen = ''; if (isSet($_POST[$menuName])) $_SESSION[$menuName] = $_POST[$menuName]; if (isSet($_SESSION[$menuName])) $chosen = $_SESSION[$menuName]; $selectMenu = makeSelectMenu($menuName, $options, $chosen); */ ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage