Still doesn't work. What gives?
>>> "Kevin Stone" <[EMAIL PROTECTED]> 03/20/02 04:31PM >>> The contents of $display are a string so you must have quotes aroud it in the comparison statement. if ($display == 'false') // should work. Alternatively you could do. <select name="display"> <option value=0>True <option value=1>False </select> Now the contents of $display is an integer which will can be interpreted as a boolean value (true or false). Then you can compare it like you had. if ($display == false) -Kevin -----Original Message----- From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 20, 2002 2:24 PM To: [EMAIL PROTECTED] Subject: [PHP] Fwd: html form select list "selected" Whoops! Still won't work but that code should read: echo "<form>"; echo "<select name=\"display\">"; echo "<option value=\"true\""; if ($display==true){echo "selected";} echo ">Display"; echo "<option value=\"false\""; if ($display==false){echo "selected";} echo "selected>Don't Display"; echo "</select>"; echo "</form>"; >>> ROBERT MCPEAK 03/20/02 04:20PM >>> I'd like to determine the selected option in a select list based on a passed variable. The code below won't work, but I can't figure out why. Any guesses? echo "<form>"; echo "<select name=\"display\">"; echo "<option value=\"true\""; if ($display==false){echo "selected";} echo ">Display"; echo "<option value=\"false\""; if ($display==false){echo "selected";} echo "selected>Don't Display"; echo "</select>"; echo "</form>"; Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php