Forum Moderators: coopster

Message Too Old, No Replies

if Problems.

Please help!

         

TerryLM

6:35 pm on Jan 20, 2007 (gmt 0)

10+ Year Member



OK,

I can't figure out how exactly to do this...

I have 4 variables. F1-4.

If ANY of them are set, I need that F value PLUS any others to be set.

HOWEVER...

If NO values are set, I need to have a default value. ie: FF.

I'm using this to set CSS parameters. So if there are no parameters, I need the decoration to be none.

I've tried many different methods, but this is the point I'm at now...

Here's my problem:

if ($F4 + $F3 + $F2 + $F1 <= "1") {
$FF = "text-decoration: none; ";
}
else if ($F4 > "1" ¦¦ $F3 > "1" ¦¦ $F2 > "1" ¦¦ $F1 > "1") {
$FF = "";
}

I either get ALL the CSS coming up with text-decor none or none of them have the text-decor none.

This is what I have BEFORE the code above setting the variables:

if ($F1 == F1) {
$F1 = "font-weight: bold; ";
}
else {
$F1 = "";
}

if ($F2 == F2) {
$F2 = "font-style: italic; ";
}
else {
$F2 = "";
}

if ($F3 == F3) {
$F3 = "text-decoration: underline; ";
}
else {
$F3 = "";
}

if ($F4 == F4) {
$F4 = "text-decoration: overline; ";
}
else {
$F4 = "";
}

cameraman

8:07 pm on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure I really follow what you're trying to do.
If you're saying that $F1 will either contain nothing or "font-weight:bold;"
and $F2 will either contain nothing or "font-style:italic;"
et cetera
and that you want to apply all of the styles which are set but an explicit nothing if none of them are set, then I think this will work:

$FF = $F1 . $F2 . $F3 . $F4;
if($FF == '')
$FF = 'text-decoration:none;';

What that does is concatenate the four variables. If all four are empty, then it sets $FF to no decoration, although it says nothing about a default font weight or style.

The bottom half is interesting. When you say $F1, you're talking about a variable. When you say F1 you're talking about a constant. Did you define four constants? If not, we'll need a little more info about how to decide what each of the $F_ variables are going to get set.

mcibor

9:18 pm on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Terry and welcome to Webmasterworld!

I think what you need is:

if ($F1!= F1 && $F2!= F2 && $F3!= F3 && $F4!= F4) $FF = 'text-decoration: none';
else $FF = '';

Hope this helps
Michal

PS. Cameraman, (s)he never suggested that $FF should contain the output