Re: Option Value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/23/07, Dan Shirah <mrsquash2@xxxxxxxxx> wrote:

On my form I have several drop down menus.  They all work and display the
corrent values.  However, I would like the initial display of the form to
show each dropdown as blank.


$q_status = "SELECT * FROM status_codes ORDER BY status_description";
$r_status = mssql_query($q_status) or die(mssql_error());
while ($rec_status = mssql_fetch_assoc($r_status)) $status[] =
$rec_status;

foreach ($status as $s)
{
   if ($s['status_code'] == $_POST['status'])
     echo "<OPTION value=\"{$s['status_code']}\"
SELECTED>{$s['status_description']}</OPTION>\n";
   else
     echo "<OPTION
value=\"{$s['status_code']}\">{$s['status_description']}</OPTION>\n";
}

Any suggestions on how to make my initial display of the field blank
without
having to add a blank row to my table?


Meaning: you want the select box to show as a default value a blank line but
have the remaining data items from the db still in the drop-down list?  Then
you want to use the "selected" attribute on a blank line. Plenty of examples
available.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux