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');}'>";
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');}'>";
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.
still the same :(
$disabled = $stat =='a' ? 'disabled' : '';
echo "<select name='name' id='name' $disabled>";
Gotcha, thank you... Can you please explain the 1st line of the code. Thank You!
Basically it does this:
if ($stat =='a')
$disabled = 'disabled';
else
$disabled = '';
See:
http://php.net/manual/en/language.operators.comparison.php
Scroll down to "Ternary operator".
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.">";
No fang. Simple Variables can be parsed within double quotes. There is no need to concatenate them.
i'll never write the code that way, i thought it will be read as string.
I'll try it. thank you
Thank You Guys for your help :D
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.