This topic is locked

change font color

10/29/2008 11:33:01 PM
ASPRunnerPro General questions
D
ducky author

hi. i can change the font color on the editor list screen and it works fine. but i want to be able to change the font color (not bg) based on a criteria between two colors during run time.
for example, if the user's title is miss i want to display it in green, if it's mrs then blue.
specifying the color is not the problem, but i don't know where or how to code it. i think it has to be a custom display.
thank you

M
myPCdoctor 10/30/2008

One of my develoeprs tried to do this some time ago with no success. She thought the same thing "Custom DisplaY". The problem is is that any code such as required to change font colors etc in the list page, will be the default value on the ADD Page. Not at all what you want.
We tried several different ways, and left posts here and got nothing. We even tried this code below (taken from tips, but it works fine). The script is displayed on the EDIT Page as a default value!
We now think that it has to be an event, but getting help on events can be difficult as most people here are volunteers and have real lives.
Maybe it can help you and if you figure out how to do this in an event, please post.
str = "<table width=100% bgcolor="

strFont = "" this can be changed later, but is not relevant here
if strValue<0 then
Admin account, set Background to Green

str = str & "green"

end if
if strValue=0 then guest account, set Background to red to flag it

str = str & "red"

end if
if strValue>0 AND strValue=1 then
standard user, set to blue

str = str & "blue"

end if
str = str & "><tr><td><b><font"& strFont &">" & strValue & "</font></b></td></tr></table>"

strValue = str

Sergey Kornilov admin 10/30/2008

ducky,
here is how you can do this. I assume that field names are Name and Title. Set 'View as' type of Name field to 'Custom' and use the following code:

if rs("Title")="mrs" then

strValue = "<font color=blue>" & strValue & "</font>"

else

strValue = "<font color=greeen>" & strValue & "</font>"

end if


myPCdoctor,
if Custom code appears as default value on Edit page something is wrong and you need to contact support.

D
ducky author 10/30/2008

Thankyou sir, you are the man. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=34595&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
My next challenge will be to disable/enable add/edit/delete links. That otta be fun. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=34595&image=2&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
Cool product, thanks again for the help.
Ducky.

Sergey Kornilov admin 10/30/2008

Ducky,
I recommend to check user group permissions for this purpose.

R
rascasse83 12/1/2008

Sergey
the Custom code idea on the Visual Editor works, but only if i removed the reference to the rs() variable.
Indeed leaving the rs variable in the custom code brough the following error when clicking on a master-to-detail link.
"Item cannot be found in the collection corresponding to the requested name or ordinal".
So the bit that worked is below (i replaced the rs variable by the strValue variable)
if strValue="mrs" then

strValue = "<font color=blue>" & strValue & "</font>"

else

strValue = "<font color=greeen>" & strValue & "</font>"

end if