Disabled select drop down displays more than one line

Hello all,

The following code disables the select but it continues to show more than one line in the drop down. The condition should only display one disabled line.

Can someone tell me why?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


echo "<br /><br /><br /><br />";

function selected($opt1,$opt2) {
    if ($opt1 === $opt2) echo 'selected="selected"';

function disabled($opt1,$opt2) {
    if ($opt1 === $opt2) echo 'disabled="disabled"';

$candidacy4 = "4";

echo '<select id="candidacy4" name="candidacy4">'."  \
if ($candidacy4 != "4") { ?>
    <option <?php selected($candidacy4,"4");?> value="4">Accepted</option>
    <option <?php selected($candidacy4,"0");?> value="0">Not Accepted</option>
<?php } else { ?>
    <option <?php disabled($candidacy4,"4");?> >Accepted</option>
    } // end if
echo "  \
echo '</select>&nbsp; why is this doing this?'."  \



Where in the script do you first assign a value to $candidacy4 because in the code you have there it never gets assigned a value.

$candidacy4 = “4”; is in his code with double quotes and the if has double quotes.

The script is working because you are asking if $candidacy4 does not equal 4 to display the selection or else if it is equal to 4 display accepted (disabled).

What is it that you want it to do?

At the w3school site, the normal output shows one select line greyed out.

In my routine, with the variable = 4, the pulldown shows a blank line followed by a greyed out line.

My code is an except. I am getting the variable from a table and if the variable is equal to a condition “4” then it should only provide the one select line disabled.

Does anyone see something in my code that allows it to show more than one line when = 4?

When I ran your code I got

<select id="candidacy4" name="candidacy4">  
<option disabled="disabled" >Accepted</option>

Only one option that is disabled.

I knew I should have mentioned the browser!

I usually do my testing using FF but after your post, I checked using IE and it shows it differently.

Any ideas as to how to correct this for FF?

why don’t you show your HTML code?
How can we help without seeing it?

I ran the script and it had problems in ff. viewed the source and made a new file with just the html source and it worked fine.

This doesn’t make sense.

I did a search on the net and found some references to this problem but they were years ago when the browsers were older.

I will try creating a new file using the same code, thanks.