Click to See Complete Forum and Search --> : [RESOLVED] alter font colour within text box


roscor
01-04-2007, 05:37 PM
Hi,

I have been trying to change the font colour within a text box. I have used a hidden box with echo but want to display within the box to continue the theme of my forms. I am stuck and been trying different methods, but with no joy any help would be greatly appreciated. current code this not working is

<? echo "";
if ($percentage >= 87.5) {
$color = '#00FF00';
} elseif ($percentage >= 37.5) {
$color = '#ff9900';
} else {
$color = 'red';
}
?>
<input type="text" name="percentage" value="<? echo '<b style="color:' . $color . '">' . $percentage . '</b>'; ?>">

thanks roscor

NogDog
01-04-2007, 06:06 PM
Is this what you mean?

<?php
printf('<input type="text" name="percentage" style="color: %s;" value="%"><br>', $color, $percentage);
?>

roscor
01-05-2007, 10:33 AM
Thanks Nogdog,

couldn't get it to work,

I played around and got this which works fine

echo "<input type='text' name='percentage' style='color: $color' value='$percentage&nbsp;%'><br>";

many thanks

roscor

(not a programmer purely an enthusiastic newbie)