Forums
This topic is locked
Conditional Colour Change
Posted 18 Oct 2007 15:45:19
1
has voted
18 Oct 2007 15:45:19 Graham Hefford posted:
Hi I have a calculation (see below) that if the result is less than the answer is in red, and if more than in white
<% Dim ShipL1Total %>
<% = Session("ShipTotals1" - Session("ShipTarget1" %>
<%if (ShipL1Total > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(ShipL1Total)</font>"
ELSE
Response.Write("<font color=#003e80>(ShipL1Total)</font>"
End If
%>
Can anyone help in getting this working
Thanks
Replies
Replied 18 Oct 2007 16:28:23
18 Oct 2007 16:28:23 Georgi Kralev replied:
Hi Graham,
Try the following code:
<i><b><%</b>
Dim ShipL1Total
ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"
<b>%></b>
<b><%</b>
if (ShipL1Total > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
<b>%></b></i>
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Try the following code:
<i><b><%</b>
Dim ShipL1Total
ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"
<b>%></b>
<b><%</b>
if (ShipL1Total > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
<b>%></b></i>
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Replied 18 Oct 2007 16:33:10
18 Oct 2007 16:33:10 Georgi Kralev replied:
Also, instead <b>font color</b> it could be used css styles.
For example:
Add the following styles to your page:
<i><style type="text/css">
<!--
<b>.smallTotal {color: #FF0000}</b>
<b>.largeTotal {color: #003e80}</b>
-->
</style></i>
And the font tag could be replaced with span tag.
For example:
<i>
<%
If (ShipL1Total > Session("ShipTarget1") then
Response.Write("<b><span class=""largeTotal""</b>>(" & ShipL1Total & "</span>"
Else
Response.Write("<b><span class=""smallTotal""</b>>(" & ShipL1Total & "</span>"
End If
%></i>
I hope that you will find this useful.
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
For example:
Add the following styles to your page:
<i><style type="text/css">
<!--
<b>.smallTotal {color: #FF0000}</b>
<b>.largeTotal {color: #003e80}</b>
-->
</style></i>
And the font tag could be replaced with span tag.
For example:
<i>
<%
If (ShipL1Total > Session("ShipTarget1") then
Response.Write("<b><span class=""largeTotal""</b>>(" & ShipL1Total & "</span>"
Else
Response.Write("<b><span class=""smallTotal""</b>>(" & ShipL1Total & "</span>"
End If
%></i>
I hope that you will find this useful.
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Replied 19 Oct 2007 15:20:29
19 Oct 2007 15:20:29 Graham Hefford replied:
Hi George
Thanks for the code, I have tryed this and the colour does not change it stays red
Regards
Thanks for the code, I have tryed this and the colour does not change it stays red
Regards
Replied 19 Oct 2007 15:46:52
19 Oct 2007 15:46:52 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi George
Thanks for the code, I have tryed this and the colour does not change it stays red
Regards
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
The color of the text depend on your calculation.
Check the following statements:
<i>ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"</i>
and
<i>If (ShipL1Total > Session("ShipTarget1") then</i>
If you want the color to change set value which satisfy the if condition
To do that check the following code:
<%
<b>Session("ShipTotals1" = 1000
Session("ShipTarget1" = 400</b>
Dim ShipL1Total
ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"
%>
<%
if (ShipL1Total > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
%>
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Hi George
Thanks for the code, I have tryed this and the colour does not change it stays red
Regards
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
The color of the text depend on your calculation.
Check the following statements:
<i>ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"</i>
and
<i>If (ShipL1Total > Session("ShipTarget1") then</i>
If you want the color to change set value which satisfy the if condition
To do that check the following code:
<%
<b>Session("ShipTotals1" = 1000
Session("ShipTarget1" = 400</b>
Dim ShipL1Total
ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1"
%>
<%
if (ShipL1Total > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
%>
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Replied 22 Oct 2007 18:32:24
22 Oct 2007 18:32:24 Graham Hefford replied:
George Thanks for your contiuning help... Heres the test code. The colours still not change.
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/AS400Test1.asp" -->
<%
Dim DisplayBoard
Dim DisplayBoard_cmd
Dim DisplayBoard_numRows
Set DisplayBoard_cmd = Server.CreateObject ("ADODB.Command"
DisplayBoard_cmd.ActiveConnection = MM_AS400Test1_STRING
DisplayBoard_cmd.CommandText = "SELECT * FROM DTWMS.WMMB6"
DisplayBoard_cmd.Prepared = true
Set DisplayBoard = DisplayBoard_cmd.Execute
DisplayBoard_numRows = 0
%>
<style type="text/css">
<!--
.smallTotal {color: #FF0000}
.largeTotal {color: #003e80}
-->
</style>
<%
Session("ShipTotals1" = Abs((DisplayBoard.Fields.Item("MBSHX1".Value))
Session("ShipTotals2" = Abs((DisplayBoard.Fields.Item("MBSHX2".Value))
Session("ShipTarget1" = Abs((DisplayBoard.Fields.Item("MBSPX1".Value))
Session("ShipTarget2" = Abs((DisplayBoard.Fields.Item("MBSPX2".Value))
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<% Dim ShipL1Total %>
<% ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1" %>
<% Session("ShipTarget2" = ShipL1Total %>
<%
If (Session("ShipL1Total" > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
%>
<%
DisplayBoard.Close()
Set DisplayBoard = Nothing
%>
Any ideas....
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/AS400Test1.asp" -->
<%
Dim DisplayBoard
Dim DisplayBoard_cmd
Dim DisplayBoard_numRows
Set DisplayBoard_cmd = Server.CreateObject ("ADODB.Command"
DisplayBoard_cmd.ActiveConnection = MM_AS400Test1_STRING
DisplayBoard_cmd.CommandText = "SELECT * FROM DTWMS.WMMB6"
DisplayBoard_cmd.Prepared = true
Set DisplayBoard = DisplayBoard_cmd.Execute
DisplayBoard_numRows = 0
%>
<style type="text/css">
<!--
.smallTotal {color: #FF0000}
.largeTotal {color: #003e80}
-->
</style>
<%
Session("ShipTotals1" = Abs((DisplayBoard.Fields.Item("MBSHX1".Value))
Session("ShipTotals2" = Abs((DisplayBoard.Fields.Item("MBSHX2".Value))
Session("ShipTarget1" = Abs((DisplayBoard.Fields.Item("MBSPX1".Value))
Session("ShipTarget2" = Abs((DisplayBoard.Fields.Item("MBSPX2".Value))
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<% Dim ShipL1Total %>
<% ShipL1Total = Session("ShipTotals1" - Session("ShipTarget1" %>
<% Session("ShipTarget2" = ShipL1Total %>
<%
If (Session("ShipL1Total" > Session("ShipTarget1") then
Response.Write("<font color=#003e80>(" & ShipL1Total & "</font>"
Else
Response.Write("<font color=#FF0000>(" & ShipL1Total & "</font>"
End If
%>
<%
DisplayBoard.Close()
Set DisplayBoard = Nothing
%>
Any ideas....
Replied 23 Oct 2007 10:07:14
23 Oct 2007 10:07:14 Georgi Kralev replied:
Hi Graham,
As I mentioned before:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>The color of the text depend on your calculation<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Therefore, if the color is not right check your calculation or the values which you assign:
I my opinion your If statement is wrong.
This is because I do not see the following session variable to be initialized: <b>Session("ShipL1Total"</b>
Therefore it have to look like this:
If (<b>ShipL1Total</b> > Session("ShipTarget1") then
OR
If (<b>Session("ShipTarget2"</b> > Session("ShipTarget1") then
(Because of the following statement: Session("ShipTarget2" = ShipL1Total)
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
As I mentioned before:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>The color of the text depend on your calculation<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Therefore, if the color is not right check your calculation or the values which you assign:
I my opinion your If statement is wrong.
This is because I do not see the following session variable to be initialized: <b>Session("ShipL1Total"</b>
Therefore it have to look like this:
If (<b>ShipL1Total</b> > Session("ShipTarget1") then
OR
If (<b>Session("ShipTarget2"</b> > Session("ShipTarget1") then
(Because of the following statement: Session("ShipTarget2" = ShipL1Total)
Regards,
Georgi Kralev
----------------------------------
Support - www.DMXzone.com
Replied 23 Oct 2007 12:30:01
23 Oct 2007 12:30:01 Graham Hefford replied:
George
I am very sorry about bothering you with this, but its doing my head in.
The if statement works ish...
Lets say the valve is positive, the colour works, the valve then changes on a update to a negative the colour turns red. As the statement is designed to do.
However, the the valve goes back to a positive after a update the colour stays red?
Any ideas?
Sorry once again
I am very sorry about bothering you with this, but its doing my head in.
The if statement works ish...
Lets say the valve is positive, the colour works, the valve then changes on a update to a negative the colour turns red. As the statement is designed to do.
However, the the valve goes back to a positive after a update the colour stays red?
Any ideas?
Sorry once again