I need to change my background color based on the results of a query.
For example, if the value returned by my query is within 100 - 150, my
background color should be green. If it's 150-200, it would be red,
etc. I am using Frontpage Database componets to attach to this
database.

Thanks,
Brian

Re: How to update page background color based on returned query value from SQL by Stefan

Stefan
Tue Feb 13 03:47:57 CST 2007

Select the table w/ the DBRW value and Before it in code view add

<%
TestValue = FieldVal(fp_rs,"name")
IF IsNumeric(TestValue) THEN 'Make sure it is a number
IF TestValue <100 THEN
strColor ="blue" 'Default if lower than special colors
ELSEIF TestValue <=150 AND THEN
strColor ="green"
ELSEIF TestValue <=200 THEN
strColor ="red"
' Additiontal values ranges here as more ELSEIF
ELSE
strColor ="purple" 'Default if none of above
END IF
END IF
% >

Then find your table cell w/ the DBRW value and change it to
From
<td><%=FP_FieldVal(fp_rs,"name")%></td>
To
<td background="<%=strColor%>"><%=FP_FieldVal(fp_rs,"name")%></td>


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


"Techhead" <jorgenson.b@gmail.com> wrote in message news:1171302337.707527.298540@q2g2000cwa.googlegroups.com...
|I need to change my background color based on the results of a query.
| For example, if the value returned by my query is within 100 - 150, my
| background color should be green. If it's 150-200, it would be red,
| etc. I am using Frontpage Database componets to attach to this
| database.
|
| Thanks,
| Brian
|



Re: How to update page background color based on returned query value from SQL by Techhead

Techhead
Wed Feb 14 09:45:57 CST 2007

On Feb 13, 3:47 am, "Stefan B Rusynko" <sbr_en...@hotmail.com> wrote:
> Select the table w/ the DBRW value and Before it in code view add
>
> <%
> TestValue = FieldVal(fp_rs,"name")
> IF IsNumeric(TestValue) THEN 'Make sure it is a number
> IF TestValue <100 THEN
> strColor ="blue" 'Default if lower than special colors
> ELSEIF TestValue <=150 AND THEN
> strColor ="green"
> ELSEIF TestValue <=200 THEN
> strColor ="red"
> ' Additiontal values ranges here as more ELSEIF
> ELSE
> strColor ="purple" 'Default if none of above
> END IF
> END IF
> % >
>
> Then find your table cell w/ the DBRW value and change it to
> From
> <td><%=FP_FieldVal(fp_rs,"name")%></td>
> To
> <td background="<%=strColor%>"><%=FP_FieldVal(fp_rs,"name")%></td>
>
> --
>
> _____________________________________________
> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
> "Warning - Using the F1 Key will not break anything!" (-;
> _____________________________________________
>
> "Techhead" <jorgenso...@gmail.com> wrote in messagenews:1171302337.707527.298540@q2g2000cwa.googlegroups.com...
>
> |I need to change my background color based on the results of a query.
> | For example, if the value returned by my query is within 100 - 150, my
> | background color should be green. If it's 150-200, it would be red,
> | etc. I am using Frontpage Database componets to attach to this
> | database.
> |
> | Thanks,
> | Brian
> |

I am trying to use this code:

<%
CenValue = request.QueryString("SELECT * FROM Census")
IF IsNumeric(CenValue) THEN
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue <=160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
END IF
%>

<body bgcolor="<%=strColor%>">

My value for "cenvalue" is 146 but my color is still coming back as
green. For some reason it see's the cenvalue as less than 140 but it
is not. Any ideas?


Re: How to update page background color based on returned query value from SQL by Steve

Steve
Wed Feb 14 19:17:27 CST 2007


"Techhead" <jorgenson.b@gmail.com> wrote in message news:1171467957.772444.226580@j27g2000cwj.googlegroups.com...
> On Feb 13, 3:47 am, "Stefan B Rusynko" <sbr_en...@hotmail.com> wrote:
>> Select the table w/ the DBRW value and Before it in code view add
>>
>> <%
>> TestValue = FieldVal(fp_rs,"name")
>> IF IsNumeric(TestValue) THEN 'Make sure it is a number
>> IF TestValue <100 THEN
>> strColor ="blue" 'Default if lower than special colors
>> ELSEIF TestValue <=150 AND THEN
>> strColor ="green"
>> ELSEIF TestValue <=200 THEN
>> strColor ="red"
>> ' Additiontal values ranges here as more ELSEIF
>> ELSE
>> strColor ="purple" 'Default if none of above
>> END IF
>> END IF
>> % >
>>
>> Then find your table cell w/ the DBRW value and change it to
>> From
>> <td><%=FP_FieldVal(fp_rs,"name")%></td>
>> To
>> <td background="<%=strColor%>"><%=FP_FieldVal(fp_rs,"name")%></td>
>>
>> --
>>
>> _____________________________________________
>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
>> "Warning - Using the F1 Key will not break anything!" (-;
>> _____________________________________________
>>
>> "Techhead" <jorgenso...@gmail.com> wrote in messagenews:1171302337.707527.298540@q2g2000cwa.googlegroups.com...
>>
>> |I need to change my background color based on the results of a query.
>> | For example, if the value returned by my query is within 100 - 150, my
>> | background color should be green. If it's 150-200, it would be red,
>> | etc. I am using Frontpage Database componets to attach to this
>> | database.
>> |
>> | Thanks,
>> | Brian
>> |
>
> I am trying to use this code:
>
> <%
> CenValue = request.QueryString("SELECT * FROM Census")
> IF IsNumeric(CenValue) THEN
> IF CenValue <140 THEN
> strColor ="green"
> ELSEIF CenValue <=160 THEN
> strColor ="yellow"
> ELSEIF CenValue >=160 THEN
> strColor ="red"
> END IF
> END IF
> %>
>
> <body bgcolor="<%=strColor%>">
>
> My value for "cenvalue" is 146 but my color is still coming back as
> green. For some reason it see's the cenvalue as less than 140 but it
> is not. Any ideas?

Because IF CenValue <140 and ElseIf CenValue <=160 are both true so the first condition still applies.
Try testing for CenValue to be greater than 140 but less than 160 using AndIf

--
Steve Easton
Microsoft MVP FrontPage
FP Cleaner
http://www.95isalive.com/fixes/fpclean.htm
Hit Me FP
http://www.95isalive.com/fixes/HitMeFP.htm
Coming Soon: Function5 Auto Refresh




Re: How to update page background color based on returned query value from SQL by Stefan

Stefan
Thu Feb 15 03:17:09 CST 2007


What does this return?
CenValue = request.QueryString("SELECT * FROM Census")

The use of request.QueryString returns a value from a parameter passed in a URL
as in:

CenValue = request.QueryString("CenValue") from say
somepage.asp?CenValue=XXX

In your case it is returning nothing or 0

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


"Techhead" <jorgenson.b@gmail.com> wrote in message news:1171467957.772444.226580@j27g2000cwj.googlegroups.com...
| On Feb 13, 3:47 am, "Stefan B Rusynko" <sbr_en...@hotmail.com> wrote:
| > Select the table w/ the DBRW value and Before it in code view add
| >
| > <%
| > TestValue = FieldVal(fp_rs,"name")
| > IF IsNumeric(TestValue) THEN 'Make sure it is a number
| > IF TestValue <100 THEN
| > strColor ="blue" 'Default if lower than special colors
| > ELSEIF TestValue <=150 AND THEN
| > strColor ="green"
| > ELSEIF TestValue <=200 THEN
| > strColor ="red"
| > ' Additiontal values ranges here as more ELSEIF
| > ELSE
| > strColor ="purple" 'Default if none of above
| > END IF
| > END IF
| > % >
| >
| > Then find your table cell w/ the DBRW value and change it to
| > From
| > <td><%=FP_FieldVal(fp_rs,"name")%></td>
| > To
| > <td background="<%=strColor%>"><%=FP_FieldVal(fp_rs,"name")%></td>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| > "Techhead" <jorgenso...@gmail.com> wrote in messagenews:1171302337.707527.298540@q2g2000cwa.googlegroups.com...
| >
| > |I need to change my background color based on the results of a query.
| > | For example, if the value returned by my query is within 100 - 150, my
| > | background color should be green. If it's 150-200, it would be red,
| > | etc. I am using Frontpage Database componets to attach to this
| > | database.
| > |
| > | Thanks,
| > | Brian
| > |
|
| I am trying to use this code:
|
| <%
| CenValue = request.QueryString("SELECT * FROM Census")
| IF IsNumeric(CenValue) THEN
| IF CenValue <140 THEN
| strColor ="green"
| ELSEIF CenValue <=160 THEN
| strColor ="yellow"
| ELSEIF CenValue >=160 THEN
| strColor ="red"
| END IF
| END IF
| %>
|
| <body bgcolor="<%=strColor%>">
|
| My value for "cenvalue" is 146 but my color is still coming back as
| green. For some reason it see's the cenvalue as less than 140 but it
| is not. Any ideas?
|