On Fri, Dec 20, 2013 at 6:08 PM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote: > On Fri, 2013-12-20 at 18:03 -0500, Larry Martell wrote: >> I have a listbox and when the user selects items they are highlighted. Then >> I process the form and when I generate the next web page (which has the >> listbox) I want the selected items still to be highlighted. Can I do this >> from PHP when I generate the listbox or must that be done client side from >> javascript? > > Yes, it's pretty easy, here's an example: > > <select name="colour"> > <?php > $colours = array('red','blue','green','yellow'); > > foreach($colours as $colour) > { > $selected = (isset($_POST['colour']) && $colour == > $_POST['colour'])?'selected="selected"':''; > > echo "<option value=\"$colour\" $selected>$colour</option>"; > } > ?> > </select> Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php