How to update page background color based on returned query value from SQL

T

Techhead

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
 
S

Stefan B Rusynko

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!" (-;
_____________________________________________


|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
|
 
T

Techhead

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!" (-;
_____________________________________________


|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?
 
S

Steve Easton

Techhead said:
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!" (-;
_____________________________________________


|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
 
S

Stefan B Rusynko

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!" (-;
_____________________________________________


| > 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!" (-;
| > _____________________________________________
| >
| >
| > |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?
|
 
R

Ronx

Techhead said:
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!" (-;
_____________________________________________


|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


146 < 140 ?

I don't think a SQL statement is valid when used as a querystring
parameter name
CenValue = request.QueryString("SELECT * FROM Census")
Also, the CenValue retrived from request.Querystring("parameter") will
be a string, which when compared to a number will probably have a
numeric value of 0 - this is less than 140.

I am not sure if CenValue is supposed to come from a parameter in a link
from another page, or from a database query.
If from the parameter
Then
Cenvalue = Cint(request.Querystring("parameterName"))
Would be better (if integer values are involved.
 
S

Stefan B Rusynko

IMHO
It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)

Better to always check it first using

IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

--

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


| |
| > >> 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |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
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numeric value of 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a database query.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
| FrontPage Support: http://www.frontpagemvps.com/
| http://www.rxs-enterprises.org/fp
|
 
T

Techhead

IMHO
It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)

Better to always check it first using

IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

--

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


||
| > >> 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |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
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numeric value of 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a database query.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
| FrontPage Support: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|

OK, I am taking a step back and trying to get my comparison operators
right.

I changed my code to the following:

<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>

This time I am explicitly setting the CenValue. However, if I use
ANDIF, I get an error expecting another THEN. I am not worried about
my request.querystring value at this time, but I just need to get my
operators syntax correct.

-Brian
 
T

Techhead

IMHO
It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
"Ronx" <[email protected]> wrote in messagenews:%[email protected]...
||
| > >> 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |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
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numeric value of 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a database query.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
| FrontPage Support: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|

OK, I am taking a step back and trying to get my comparison operators
right.

I changed my code to the following:

<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>

This time I am explicitly setting the CenValue. However, if I use
ANDIF, I get an error expecting another THEN. I am not worried about
my request.querystring value at this time, but I just need to get my
operators syntax correct.

-Brian- Hide quoted text -

- Show quoted text -

Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correct value. Thanks!
 
T

Techhead

IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -

Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -

- Show quoted text -

Since I can't use request.querystring to retrieve the value I need,
what other options do I have?
 
R

Ronx

Where is the value coming from?

--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/
http://www.rxs-enterprises.org/fp



On Feb 15, 4:35 am, "Stefan B Rusynko" <[email protected]> wrote:
IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
"Ronx" <[email protected]> wrote in messagenews:%[email protected]...
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -

Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -

- Show quoted text -

Since I can't use request.querystring to retrieve the value I need,
what other options do I have?
 
S

Stefan B Rusynko

That is because there is no such thing as AND IF or ANDIF in ASP

See http://www.w3schools.com/asp/default.asp

--

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


| > IMHO
| > It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an
integer
| > (not empty or null or text that can't be converted to an integer - which will all generate errors)
| >
| > Better to always check it first using
| >
| > IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > || > |
| > | > >> 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!" (-;
| > | > >> _____________________________________________
| > | > >>
| > | > >>
| > | > >> |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
| > |
| > |
| > | 146 < 140 ?
| > |
| > | I don't think a SQL statement is valid when used as a querystring
| > | parameter name
| > | CenValue = request.QueryString("SELECT * FROM Census")
| > | Also, the CenValue retrived from request.Querystring("parameter") will
| > | be a string, which when compared to a number will probably have a
| > | numeric value of 0 - this is less than 140.
| > |
| > | I am not sure if CenValue is supposed to come from a parameter in a link
| > | from another page, or from a database query.
| > | If from the parameter
| > | Then
| > | Cenvalue = Cint(request.Querystring("parameterName"))
| > | Would be better (if integer values are involved.
| > | --
| > | Ron Symonds - Microsoft MVP (FrontPage)
| > | Reply only to group - emails will be deleted unread.
| > | FrontPage Support: http://www.frontpagemvps.com/
| > |http://www.rxs-enterprises.org/fp
| > |
|
| OK, I am taking a step back and trying to get my comparison operators
| right.
|
| I changed my code to the following:
|
| <%
| CenValue = 155
| IF CenValue <140 THEN
| strColor ="green"
| ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
| strColor ="yellow"
| ELSEIF CenValue >=160 THEN
| strColor ="red"
| END IF
| %>
|
| This time I am explicitly setting the CenValue. However, if I use
| ANDIF, I get an error expecting another THEN. I am not worried about
| my request.querystring value at this time, but I just need to get my
| operators syntax correct.
|
| -Brian
|
 
S

Stefan B Rusynko

If CenValue is actually being passed by a parameter as in from
somepagelink.asp?CenValue=155

<%
If Request.Querystring("CenValue")<>"" THEN CenValue = Request.Querystring("CenValue")
If IsNumeric(CenValue) THEN
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 AND CenValue <160 THEN
strColor ="yellow"
ELSE
strColor ="red"
END IF
ELSE
strColor ="black" 'bad value passed
END IF
%>


--

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


| >
| >
| >
| >
| >
| > > IMHO
| > > It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an
integer
| > > (not empty or null or text that can't be converted to an integer - which will all generate errors)
| >
| > > Better to always check it first using
| >
| > > IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
| >
| > > --
| >
| > > _____________________________________________
| > > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > > "Warning - Using the F1 Key will not break anything!" (-;
| > > _____________________________________________
| >
| >
| > > || > > |
| > > | > >> 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!" (-;
| > > | > >> _____________________________________________
| > > | > >>
| > > | > >>
| > > | > >> |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
| > > |
| > > |
| > > | 146 < 140 ?
| > > |
| > > | I don't think a SQL statement is valid when used as a querystring
| > > | parameter name
| > > | CenValue = request.QueryString("SELECT * FROM Census")
| > > | Also, the CenValue retrived from request.Querystring("parameter") will
| > > | be a string, which when compared to a number will probably have a
| > > | numeric value of 0 - this is less than 140.
| > > |
| > > | I am not sure if CenValue is supposed to come from a parameter in a link
| > > | from another page, or from a database query.
| > > | If from the parameter
| > > | Then
| > > | Cenvalue = Cint(request.Querystring("parameterName"))
| > > | Would be better (if integer values are involved.
| > > | --
| > > | Ron Symonds - Microsoft MVP (FrontPage)
| > > | Reply only to group - emails will be deleted unread.
| > > | FrontPage Support: http://www.frontpagemvps.com/
| > > |http://www.rxs-enterprises.org/fp
| > > |
| >
| > OK, I am taking a step back and trying to get my comparison operators
| > right.
| >
| > I changed my code to the following:
| >
| > <%
| > CenValue = 155
| > IF CenValue <140 THEN
| > strColor ="green"
| > ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
| > strColor ="yellow"
| > ELSEIF CenValue >=160 THEN
| > strColor ="red"
| > END IF
| > %>
| >
| > This time I am explicitly setting the CenValue. However, if I use
| > ANDIF, I get an error expecting another THEN. I am not worried about
| > my request.querystring value at this time, but I just need to get my
| > operators syntax correct.
| >
| > -Brian- Hide quoted text -
| >
| > - Show quoted text -
|
| Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
| All I need now is to figure out my querystring so it returns the
| correct value. Thanks!
|
 
T

Techhead

Where is the value coming from?

--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/http://www.rxs-enterprises.org/fp




IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -
Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -
- Show quoted text -
Since I can't use request.querystring to retrieve the value I need,
what other options do I have?- Hide quoted text -

- Show quoted text -

The value is coming from a SQL view (SELECT * FROM TotalCensus)
 
T

Techhead

If CenValue is actually being passed by a parameter as in from
somepagelink.asp?CenValue=155

<%
If Request.Querystring("CenValue")<>"" THEN CenValue = Request.Querystring("CenValue")
If IsNumeric(CenValue) THEN
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 AND CenValue <160 THEN
strColor ="yellow"
ELSE
strColor ="red"
END IF
ELSE
strColor ="black" 'bad value passed
END IF
%>

--

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


| >
| >
| >
| >
| >
| > > IMHO
| > > It is dangerous coding practice to run a Cint on any value that you are not 100% certain will always be convertable to an
integer
| > > (not empty or null or text that can't be converted to an integer - which will all generate errors)
| >
| > > Better to always check it first using
| >
| > > IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
| >
| > > --
| >
| > > _____________________________________________
| > > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > > "Warning - Using the F1 Key will not break anything!" (-;
| > > _____________________________________________
| >
| >
| > > || > > |
| > > | > >> 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!" (-;
| > > | > >> _____________________________________________
| > > | > >>
| > > | > >>
| > > | > >> |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
| > > |
| > > |
| > > | 146 < 140 ?
| > > |
| > > | I don't think a SQL statement is valid when used as a querystring
| > > | parameter name
| > > | CenValue = request.QueryString("SELECT * FROM Census")
| > > | Also, the CenValue retrived from request.Querystring("parameter") will
| > > | be a string, which when compared to a number will probably have a
| > > | numeric value of 0 - this is less than 140.
| > > |
| > > | I am not sure if CenValue is supposed to come from a parameter in a link
| > > | from another page, or from a database query.
| > > | If from the parameter
| > > | Then
| > > | Cenvalue = Cint(request.Querystring("parameterName"))
| > > | Would be better (if integer values are involved.
| > > | --
| > > | Ron Symonds - Microsoft MVP (FrontPage)
| > > | Reply only to group - emails will be deleted unread.
| > > | FrontPage Support: http://www.frontpagemvps.com/
| > > |http://www.rxs-enterprises.org/fp
| > > |
| >
| > OK, I am taking a step back and trying to get my comparison operators
| > right.
| >
| > I changed my code to the following:
| >
| > <%
| > CenValue = 155
| > IF CenValue <140 THEN
| > strColor ="green"
| > ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
| > strColor ="yellow"
| > ELSEIF CenValue >=160 THEN
| > strColor ="red"
| > END IF
| > %>
| >
| > This time I am explicitly setting the CenValue. However, if I use
| > ANDIF, I get an error expecting another THEN. I am not worried about
| > my request.querystring value at this time, but I just need to get my
| > operators syntax correct.
| >
| > -Brian- Hide quoted text -
| >
| > - Show quoted text -
|
| Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
| All I need now is to figure out my querystring so it returns the
| correct value. Thanks!
|

Nope, Cenvalue is being taken from SQL

<%
fp_sQry="SELECT * FROM TotalCensus"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No
records returned.</td></tr>"
fp_sDataConn="Census"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&TotalCensus=3&"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=15
fp_iRegion=BOTID
%>
 
R

Ronx

Where is the value coming from?

--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/http://www.rxs-enterprises.org/fp




On Feb 15, 11:25 am, "Techhead" <[email protected]> wrote:
On Feb 15, 4:35 am, "Stefan B Rusynko" <[email protected]> wrote:
IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
"Ronx" <[email protected]> wrote in messagenews:%[email protected]...
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -
Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -
- Show quoted text -
Since I can't use request.querystring to retrieve the value I need,
what other options do I have?- Hide quoted text -

- Show quoted text -

The value is coming from a SQL view (SELECT * FROM TotalCensus)


Then Stefan's reply from last Tuesday will work: (modified for your
values)

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

Change "name" to the name of the field containing the value for
CenValue.
 
T

Techhead

Where is the value coming from?
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/http://www.rxs-enterprises.org/fp

IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -
Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -
- Show quoted text -
Since I can't use request.querystring to retrieve the value I need,
what other options do I have?- Hide quoted text -
- Show quoted text -
The value is coming from a SQL view (SELECT * FROM TotalCensus)

Then Stefan's reply from last Tuesday will work: (modified for your
values)

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

Change "name" to the name of the field containing the value for
CenValue.

--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/http://www.rxs-enterprises.org/fp- Hide quoted text -

- Show quoted text -

Using "FieldVal" comes back with a Type Mismatch. Is FieldVal an
object?
 
T

Techhead

Where is the value coming from?
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support: http://www.frontpagemvps.com/http://www.rxs-enterprises.org/fp

IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -
Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -
- Show quoted text -
Since I can't use request.querystring to retrieve the value I need,
what other options do I have?- Hide quoted text -
- Show quoted text -
The value is coming from a SQL view (SELECT * FROM TotalCensus)
Then Stefan's reply from last Tuesday will work: (modified for your
values)
<%
CenValue = FieldVal(fp_rs,"name")
IF IsNumeric(CenValue) THEN 'Make sure it is a number
IF CenValue <140 THEN
strColor ="blue" 'Default if lower than special colors
ELSEIF CenValue <=160 AND THEN
strColor ="green"
ELSEIF CenValue >160 THEN
strColor ="red"
' Additiontal values ranges here as more ELSEIF
ELSE
strColor ="purple" 'Default if none of above
END IF
END IF
% >
Change "name" to the name of the field containing the value for
CenValue.
- Show quoted text -

Using "FieldVal" comes back with a Type Mismatch. Is FieldVal an
object?- Hide quoted text -

- Show quoted text -

I was playing around and used fp_FieldVal and now it works!!! Thanks
everybody.

This is what I have:

<%
CenValue = fp_FieldVal(fp_rs,"TotalCensus")

IF CenValue <140 THEN
strColor ="#006400"
ELSEIF CenValue >=140 AND CenValue <160 THEN
strColor ="#FFD700"
ELSEIF CenValue >=160 THEN
strColor ="#B22222"
END IF

%>
 
R

Ronx

Using "FieldVal" comes back with a Type Mismatch. Is FieldVal an
object?

Fieldval is a function used in FrontPage database wizards, which you
seem to be using.


Try this instead of the first lines:

TestValue = FieldVal(fp_rs,"name")
if IsNumeric(TestValue) THEN 'Make sure it is a number
CenValue = cInt(TestValue)
if CenValue < 140 etc...

The type mismatch error indicates that CenValue and the value stored in
the database are two different types of variable, such as text and
numeric or vice versa.
 
R

Ronx

Where is the value coming from?
On Feb 15, 11:25 am, "Techhead" <[email protected]> wrote:
On Feb 15, 4:35 am, "Stefan B Rusynko" <[email protected]> wrote:
IMHO
It is dangerous coding practice to run a Cint on anyvaluethat you are not 100% certain will always be convertable to an integer
(not empty or null or text that can't be converted to an integer - which will all generate errors)
Better to always check it first using
IF IsNumeric(request.Querystring("parameterName")) THEN Cenvalue = Cint(request.Querystring("parameterName"))

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP -FrontPage]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
"Ronx" <[email protected]> wrote in messagenews:%[email protected]...
||
| > >> Select the table w/ the DBRWvalueand 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 DBRWvalueand 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!" (-;
| > >> _____________________________________________
| > >>
| > >>
| > >> |I need to change my background color based on the results of aquery.
| > >> | For example, if thevaluereturned by myqueryis within 100 - 150, my
| > >> | background color should be green. If it's 150-200, it would be red,
| > >> | etc. I am usingFrontpageDatabase 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%>">
| > >
| > > Myvaluefor "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 MVPFrontPage
| > FP Cleaner
| >http://www.95isalive.com/fixes/fpclean.htm
| > Hit Me FP
| >http://www.95isalive.com/fixes/HitMeFP.htm
| > Coming Soon: Function5 Auto Refresh
|
|
| 146 < 140 ?
|
| I don't think a SQL statement is valid when used as a querystring
| parameter name
| CenValue = request.QueryString("SELECT * FROM Census")
| Also, the CenValue retrived from request.Querystring("parameter") will
| be a string, which when compared to a number will probably have a
| numericvalueof 0 - this is less than 140.
|
| I am not sure if CenValue is supposed to come from a parameter in a link
| from another page, or from a databasequery.
| If from the parameter
| Then
| Cenvalue = Cint(request.Querystring("parameterName"))
| Would be better (if integer values are involved.
| --
| Ron Symonds - Microsoft MVP (FrontPage)
| Reply only to group - emails will be deleted unread.
|FrontPageSupport: http://www.frontpagemvps.com/
|http://www.rxs-enterprises.org/fp
|
OK, I am taking a step back and trying togetmy comparison operators
right.
I changed my code to the following:
<%
CenValue = 155
IF CenValue <140 THEN
strColor ="green"
ELSEIF CenValue >=140 ANDIF CenValue <160 THEN
strColor ="yellow"
ELSEIF CenValue >=160 THEN
strColor ="red"
END IF
%>
This time I am explicitly setting the CenValue. However, if I use
ANDIF, Igetan error expecting another THEN. I am not worried about
my request.querystringvalueat this time, but I just need togetmy
operators syntax correct.
-Brian- Hide quoted text -
- Show quoted text -
Nevermind, I just dropped the "ANDIF" and used "AND". Works fine now.
All I need now is to figure out my querystring so it returns the
correctvalue. Thanks!- Hide quoted text -
- Show quoted text -
Since I can't use request.querystring to retrieve the value I need,
what other options do I have?- Hide quoted text -
- Show quoted text -
The value is coming from a SQL view (SELECT * FROM TotalCensus)
Then Stefan's reply from last Tuesday will work: (modified for your
values)
<%
CenValue = FieldVal(fp_rs,"name")
IF IsNumeric(CenValue) THEN 'Make sure it is a number
IF CenValue <140 THEN
strColor ="blue" 'Default if lower than special colors
ELSEIF CenValue <=160 AND THEN
strColor ="green"
ELSEIF CenValue >160 THEN
strColor ="red"
' Additiontal values ranges here as more ELSEIF
ELSE
strColor ="purple" 'Default if none of above
END IF
END IF
% >
Change "name" to the name of the field containing the value for
CenValue.
- Show quoted text -

Using "FieldVal" comes back with a Type Mismatch. Is FieldVal an
object?- Hide quoted text -

- Show quoted text -

I was playing around and used fp_FieldVal and now it works!!! Thanks
everybody.

This is what I have:

<%
CenValue = fp_FieldVal(fp_rs,"TotalCensus")

IF CenValue <140 THEN
strColor ="#006400"
ELSEIF CenValue >=140 AND CenValue <160 THEN
strColor ="#FFD700"
ELSEIF CenValue >=160 THEN
strColor ="#B22222"
END IF

%>

Great - please ignore my other post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top