in reply to Conditional statement in HTML code.
It depends on how you are building your HTML page. Are you just using strings or are you using some templating system? My guess would be for the latter, but you'll have to tell us which one.
And that's assuming you want this code to be executed on server side, not client side (ie: the color doesn't change after the page is loaded).
Edit: relying on the return value of if/else isn't very good style IMHO. But you can use the ternary operator instead which works like that: CONDITION ? VALUE_IF_TRUE : VALUE_IF_FALSE;, so in your case: my $bgcolor = ($ref->{'status'} == 'open') ? 'blue' : 'red'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conditional statement in HTML code.
by techjohnny (Novice) on Feb 06, 2018 at 18:34 UTC | |
by Eily (Monsignor) on Feb 06, 2018 at 18:39 UTC | |
by techjohnny (Novice) on Feb 06, 2018 at 18:51 UTC | |
by poj (Abbot) on Feb 06, 2018 at 18:56 UTC | |
by techjohnny (Novice) on Feb 06, 2018 at 19:03 UTC |