0

Hey guys please help me with my code, I want to disable select drop down if $stat=a, this is my code. Thank You!

echo "<select name='name' id='name' 'if ($stat =='a'){ echo ('disabled');}'>";
5
Contributors
9
Replies
36
Views
2 Years
Discussion Span
Last Post by bLuEmEzzy
0

echo "<select name='name' id='name' <?php if ($stat =='a'){ echo ('disabled');} ?> >";

I haven't actually tested that but the main point is you need the <?php ?> tags otherwise you're just going to echo out the if statement as text.

1
$disabled = $stat =='a' ? 'disabled' : '';
echo "<select name='name' id='name' $disabled>";
0

Gotcha, thank you... Can you please explain the 1st line of the code. Thank You!

1

if i may revised the code a bit, i think the second line code should be like this:

echo "<select name='name' id='name' ".$disabled.">";
0

No fang. Simple Variables can be parsed within double quotes. There is no need to concatenate them.

0

i'll never write the code that way, i thought it will be read as string.
I'll try it. thank you

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.