RE: [PHP] Multi Selection Boxes

From: Date: Wed, 03 Jan 2001 16:55:20 +0000
Subject: RE: [PHP] Multi Selection Boxes
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-32516@lists.php.net to get a copy of this message
Philip Olson ... > The key is to use name the select as an array AND signify a "multiple" > attribute to the select. An example : > > <form method="get" action="<?php print $PHP_SELF; ?>"> > <select name="colors[]" multiple> > <option name="blue">blue</option> > <option name="green">green</option> > </select> > <br><input type="submit" name="submit"> > </form> Well, i have something similar in my web project... i had to program some kind of multi-selectable options, like that, but i disagreed the idea of a <select multiple>, just because i considered the IQ of most users... don't think bad, but think about the typical user: he uses windoze, IE, has no idea of what a directory tree is, has no idea of what "megabyte" means, and has no idea of how ctrl-click something... Because of that, because of many users don't know how to ctrl-click something, i choose the checkboxes solution: <input type=check name=colors[1] value='blue'> Blue <input type=check name=colors[2] value='red'> Red <input type=check name=colors[3] value='green'> Green So that, if you want to see your multiple selection, you only have to put... if (isarray($colors)) echo implode("\n",$colors); And note that feeding that checkboxes from a database or whatever is not difficult. Also, i managed to put a very effective "type-other-option" system: <input type=check name=colors[1] value='blue'> Blue <input type=check name=colors[2] value='red'> Red <input type=check name=colors[3] value='green'> Green Other: <input type=text name=colors[4]> It works perfectly, and i think it's more easy to use by most users than the multiple-select-box.

« previous php.general (#32516) next »