I am using a very useful application known as GenericDB by Eli Robillard. I have a classic ASP application that requires that when a specific field contains user comments (not empty) pertaining to a particular field (which is numeric), that numeric field needs to be color highlighted or be marked with an asterisk when displayed on a table. The Lister in GenericDB has the following section that I think is where the modified code needs to be inserted. Any suggestion on how to make the modification would be appreciated.
Thanks.
jose -
Select Case aFields(x,2)
-
case 2, 3, 4, 5, 17 ' Integers, Reals
-
if curVal <> " " then curval = FormatNumber(curval,0,,0) 'use commas with no decimals
-
case 6 ' Currency
-
if curVal <> " " then curval = FormatCurrency(curval,0,-1) 'replaced 2 with 0 to round off numbers
-
case 11 ' Boolean
-
if curVal then
-
curVal = txtTrue
-
else
-
curVal = txtFalse
-
end if
-
case 7, 135 ' Date / Time: 0=General, 1=LongDate, 2=ShortDate, 3=LongTime, 4=hh:mm
-
if curVal <> " " then curVal = FormatDateTime(curVal, Mid(strFormatDate, x, 1))
-
case 130, 201, 202, 203, 204 ' String or Memo
-
' Image
-
if (UCase(Left(aFields(x,1),3)) = "IMG") then
-
if Session("dbMaxImageSize") = 0 then
-
curVal = "<img src=" & QUOTE & curVal & QUOTE & " alt=" & QUOTE & QUOTE & " />"
-
else
-
' Opens image in a new window. Use Session("dbMaxImageSize") to set "thumbnail" size
-
curVal = "<a href=" & QUOTE & curVal & QUOTE & " target = _new><img alt=" & QUOTE & txtClickToView & QUOTE & " src = " & QUOTE & curVal & QUOTE & " width=" & QUOTE & Session("dbMaxImageSize") & QUOTE & " />" & "</a>"
-
end if
-
IsLink = true
-
end if
-
-
Jose
You might want to look at my revised version of Genericdb
I just releasd GDBR4. It uses CSS style sheets, which is required. The Generic File are completely rewritten with somthings put into functions, but the concept is still the same.
I have a Session("dbFieldShowAs6") = "FONT,<font Color=#990000>
whis will display that field red
dbShowField as can be set to CONTAINS,FONT,TEXT and IMAGE
See my gdbHelp at "http://www.stauctions.com/GDBHelp/Default.asp
or here is the code i used.
'CAS Added for Session("dbFieldShowAsX")
if Session("dbFieldShowAs" & x) & "x" <> "x" then
arrFieldShowAs = split(Session("dbFieldShowAs" & x),",")
select case arrFieldShowAs(0) --------------------------------------
Case "FONT"
curVal = arrFieldShowAs(i+1) & curVal & "</font>"
Case "IMAGE"
for i = 1 to ubound(arrFieldShowAs) step 1
if ucase(trim(curVal)) = ucase(trim(arrFieldShowAs(i))) then curVal = "<img src=" & Quote & arrFieldShowAs(i+1) & Quote & ">"
next
Case "TEXT"
for i = 1 to ubound(arrFieldShowAs) step 2
if ucase(trim(curVal)) = ucase(trim(arrFieldShowAs(i))) then curVal = arrFieldShowAs(i+1) & curVal & "</font>"
next
Case "CONTAINS"
' To determine if a string contains a substring,
if ucase(Session("dbReplaceShowAs" & x)) = "YES" then curVal = replace(curVal," ","")
for i = 1 to ubound(arrFieldShowAs) step 2
If InStr(ucase(curVal),ucase(arrFieldShowAs(i))) <> 0 Then curVal = replace(curVal,arrFieldShowAs(i),arrFieldShowAs(i+ 1) & arrFieldShowAs(i) & "</font>")
next
Case "NOTNULL"
If curval
end select
end if
end if
6 1881
The logic seems simple enough: -
strComment=Session("comment")
-
-
'Devise a function; this is simplistic
-
-
function HighlightMe(ByVal)
-
If strComment <> "" then
-
HighlightMe = "Black"
-
Else
-
HighlightMe = "Red"
-
End If
-
end function
-
-
-
'Modify code above
-
-
If curVal <> " " then curval = HighlightMe(FormatNumber(curval,0,,0))
-
.
-
.
-
.
-
I understand that the code needs tweaking. I would appreciate any help.
Thanks.
Jose
The thing that I think is making this hard for you to grasp, is that the table code you are using has some key features that make it ideal for making a table out of an unknown db recordset. Those same features make it hard to do what you are trying to do partly because it treats the recordset as an unknown.
What I would do is look for the beginning of the loop that has the recordset.movenext command at the end (the movenext command is going to be at teh end of the loop, but you need to go to the beginning). I would declare a variable called "isCommentEmpty" and say something like this: - if recordset("commentField") = " " then
-
isCommentEmpty = true
-
end if
Then down in the line that says case 2,3,4,5,17 you need to add an if statement: - if aFields(x,2).name = "fieldName" then
-
'highlight code here
-
end if
The key to this code is you have to know which fields are which, and it's not especially compatible with what you have above.
Jared
Hi Jared:
You are right on target as regards my general feeling about the application. It is really very easy to use for simple databases but oftentimes I found myself scratching my head on how to modify it to suit my specific need. Anyway, it has helped me a lot and 'could not complain except in cases such as this one. Jared, if you think you can help me more here is the loop routine that you described above: -
<%
-
intCount = 0
-
Do While (NOT xrs.EOF) AND (intCount < intStopRec)
-
intCount = intCount + 1
-
if Cint(intCount) >= Cint(intStartRec) then %>
-
<tr> <%
-
' Get the key
-
KeyField = afields(intKey,1)
-
curKey = xrs(Keyfield)
-
if NOT (curKey & "x" = "x") then
-
if isNumeric(curkey) then
-
strLink = "KEY=" & curKey
-
else ' assume text
-
strLink = "KEY='" & LTrim(curKey) & "'"
-
' strLink = Replace(strLink," ","%20")
-
end if
-
end if
-
x = 0
-
y = 0
-
For Each xField in xrs.Fields
-
IsLink = false
-
x = x + 1 ' field no.
-
curVal = xField.Value
-
' Every other line will have a shaded background
-
bgcolor="#FFFFFF"
-
if intCount mod 2 = 0 then bgcolor=strRowColor
-
bgcolorShade = gdbShade(bgcolor)
-
if Mid(strDisplay, x, 1) = "1" then
-
y = y + 1
-
' Empty / Null / Blank
-
if IsNull(curVal) OR (Trim(curVal) & "x" = "x") then
-
curVal = " "
-
else
-
if (Mid(strTotalFields, x, 1) = "1") AND IsNumeric(curVal) then aFields(x,4) = aFields(x,4) + curVal
-
end if %>
-
<td bgcolor="<%=bgcolor%>" valign="top" <% if IsNumeric(curVal) then response.write "align=" & QUOTE & "right" & QUOTE %>><font size="<%=intFontSize%>" face="<%=strFont%>"> <%
-
' Password
-
if UCase(Left(aFields(x,1),8)) = "PASSWORD" then curVal = "*****"
-
' Everything else, by field type
-
Select Case aFields(x,2)
-
case 2, 3, 4, 5, 17 ' Integers, Reals
-
if curVal <> " " then curval = FormatNumber(curval,0,,0) 'use commas with no decimals
-
case 6 ' Currency
-
if curVal <> " " then curval = FormatCurrency(curval,0,-1) 'replaced 2 with 0 to round off numbers
-
case 11 ' Boolean
-
if curVal then
-
curVal = txtTrue
-
else
-
curVal = txtFalse
-
end if
-
case 7, 135 ' Date / Time: 0=General, 1=LongDate, 2=ShortDate, 3=LongTime, 4=hh:mm
-
if curVal <> " " then curVal = FormatDateTime(curVal, Mid(strFormatDate, x, 1))
-
case 130, 201, 202, 203, 204 ' String or Memo
-
' Image
-
if (UCase(Left(aFields(x,1),3)) = "IMG") then
-
if Session("dbMaxImageSize") = 0 then
-
curVal = "<img src=" & QUOTE & curVal & QUOTE & " alt=" & QUOTE & QUOTE & " />"
-
else
-
' Opens image in a new window. Use Session("dbMaxImageSize") to set "thumbnail" size
-
curVal = "<a href=" & QUOTE & curVal & QUOTE & " target = _new><img alt=" & QUOTE & txtClickToView & QUOTE & " src = " & QUOTE & curVal & QUOTE & " width=" & QUOTE & Session("dbMaxImageSize") & QUOTE & " />" & "</a>"
-
end if
-
IsLink = true
-
end if
-
' Check for dbEMailFor setting
-
strContainsURL = "dbemailfor" & CStr(x)
-
if (Session(strContainsURL) > 0) and NOT(IsLink) then
-
strURL = xrs(aFields(Session(strContainsURL),1))
-
if Trim(strURL) & "x" <> "x" then
-
IsLink = true
-
strURL = Replace(strURL,"mailto:","")
-
strURL = "mailto:" & LTrim(strURL)
-
curVal = "<a href=" & QUOTE & strURL & QUOTE & ">" & curVal & "</a>"
-
end if
-
end if
-
' Check for dbURLFor or dbUpload setting
-
strContainsURL = "dbURLfor" & CStr(x)
-
strContainsUpload = "dbUpload" & CStr(x)
-
if NOT(Session(strContainsUpload) & "x" = "x") and (NOT IsLink) then
-
' Convert it as though it were a dbURLFor setting
-
Session(strContainsURL) = x
-
end if
-
if (Session(strContainsURL)) > 0 AND (NOT IsLink) then
-
strURL = xrs(aFields(Session(strContainsURL),1))
-
if strURL & "x" <> "x" then
-
IsLink = true
-
curVal = "<a href=" & QUOTE & strURL & QUOTE & ">" & curVal & "</a>"
-
' *** Uncomment the following line to strip all #'s from hyperlink fields
-
' curVal = Replace(curVal,"#","")
-
end if
-
else
-
if (UCase(Left(curVal,7)) = "HTTP://") then
-
IsLink = true
-
curVal = LT & "a href=" & QUOTE & curVal & QUOTE & " target=" & QUOTE & "_blank" & QUOTE & GT & curVal & LT & "/a" & GT
-
' *** Uncomment the following line to strip all #'s from Access hyperlink fields
-
' curVal = Replace(curVal,"#","")
-
end if
-
end if
-
' Check for other hyperlink setting (dbLinkField)
-
strContainsURL = "dbLinkField" & CStr(x)
-
if (Session(strContainsURL) & "x" <> "x") AND (NOT IsLink) then
-
IsLink = true
-
if curVal & "x" <> "x" then curVal = gdbBuildLink(strContainsURL) & curVal & "</a>"
-
if left(curVal,5) = "EMPTY" then curVal = " "
-
end if
-
' Replace potentially harmful code
-
if (NOT IsLink) then curVal = gdbSterilizeText(curVal,CInt(Mid(strDispHTML, x, 1)))
-
end select
-
Response.Write curVal & " </td>"
-
end if
-
-
Next
-
-
' Show links set by dbLink
-
x = 1
-
do while NOT(Session("dbLink" & x) & "x" = "x") %>
-
<td bgcolor="<%=bgcolor%>" align="center"><font size="<%=intFontSize%>" face="<%=strFont%>"><%
-
curVal = gdbBuildLink("dbLink" & x)
-
if curVal = "EMPTY" then
-
Response.write "<a name=""BLANK"">"
-
else
-
Response.write curval
-
end if
-
response.write "</a></font>"
-
x = x + 1
-
loop
-
-
if (Session("dbDispView") <> "") and intKey > 0 then %>
-
<td bgcolor="<%=bgcolor%>" align="center"><font size="<%=intFontSize%>" face="<%=strFont%>"><a href="<%=Session("dbGenericPath")&strViewer%>?<%=strLink%>"><%=txtView%></a></td> <%
-
end if
-
if (Session("dbCanEdit") = 1) and intKey > 0 then %>
-
<td bgcolor="<%=bgcolor%>" align="center"><font size="<%=intFontSize%>" face="<%=strFont%>"><a href="<%=Session("dbGenericPath")%><%=strEditor%>?<%=strLink%>"><%=txtEdit%></a></td> <%
-
end if
-
if (Session("dbCanCopy") = 1) and session("dbCanAdd") = 1 and intKey > 0 then %>
-
<td bgcolor="<%=bgcolor%>" align="center"><font size="<%=intFontSize%>" face="<%=strFont%>"><a href="<%=Session("dbGenericPath")%><%=strEditor%>?<%=strLink%>&CMD=COPY"><%=txtCopy%></a></td> <%
-
end if
-
if (Session("dbCanDelete") = 1) and intKey > 0 then %>
-
<td bgcolor="<%=bgcolor%>" align="center"><font size="<%=intFontSize%>" face="<%=strFont%>"><a href="<%=Session("dbGenericPath")%>GenericDelete.asp?<%=strLink%>"><%=txtDelete%></a></td> <%
-
end if %>
-
</tr> <%
-
end if
-
xrs.MoveNext
-
Loop
-
-
Thanks for your help.
Jose
Jose, do you know the names of the db fields that you are talking about? What are the field names for the comment field and the numeric field that needs to be highlighted?
Jared
Hi Jared:
I got 34 of them. But for sample purposes let's use just the five of them as follows:
Numeric Field (in $):...........Comment Field (memo):
FederalAlloc....................C_FederalAlloc
StateAlloc .....................C_StateAlloc
CountyAlloc ....................C_CountyAlloc
NonNIFAAlloc....................C_NonNIFAAlloc
NIFAAlloc.......................C_NIFAAlloc
Thanks. I really appreciate you helping me on this.
Jose
Jose
You might want to look at my revised version of Genericdb
I just releasd GDBR4. It uses CSS style sheets, which is required. The Generic File are completely rewritten with somthings put into functions, but the concept is still the same.
I have a Session("dbFieldShowAs6") = "FONT,<font Color=#990000>
whis will display that field red
dbShowField as can be set to CONTAINS,FONT,TEXT and IMAGE
See my gdbHelp at "http://www.stauctions.com/GDBHelp/Default.asp
or here is the code i used.
'CAS Added for Session("dbFieldShowAsX")
if Session("dbFieldShowAs" & x) & "x" <> "x" then
arrFieldShowAs = split(Session("dbFieldShowAs" & x),",")
select case arrFieldShowAs(0) --------------------------------------
Case "FONT"
curVal = arrFieldShowAs(i+1) & curVal & "</font>"
Case "IMAGE"
for i = 1 to ubound(arrFieldShowAs) step 1
if ucase(trim(curVal)) = ucase(trim(arrFieldShowAs(i))) then curVal = "<img src=" & Quote & arrFieldShowAs(i+1) & Quote & ">"
next
Case "TEXT"
for i = 1 to ubound(arrFieldShowAs) step 2
if ucase(trim(curVal)) = ucase(trim(arrFieldShowAs(i))) then curVal = arrFieldShowAs(i+1) & curVal & "</font>"
next
Case "CONTAINS"
' To determine if a string contains a substring,
if ucase(Session("dbReplaceShowAs" & x)) = "YES" then curVal = replace(curVal," ","")
for i = 1 to ubound(arrFieldShowAs) step 2
If InStr(ucase(curVal),ucase(arrFieldShowAs(i))) <> 0 Then curVal = replace(curVal,arrFieldShowAs(i),arrFieldShowAs(i+ 1) & arrFieldShowAs(i) & "</font>")
next
Case "NOTNULL"
If curval
end select
end if
end if
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
var tmpelem;
tmpelem=document.getElementById("MyTableId");
tmpelem.select();
doesnt work - any ideas how I can get around this? I only want to
highlight the table and all child nodes.
...
|
by: Jay |
last post by:
Hi !
I am writing a page that displays a list of records in a table. Each
row for each record. Each row has a checkbox associated with it. Does
anybody know how to highlight a row when I click...
|
by: john woo |
last post by:
Hi
I'm not good at JS, but want to get more about it.
I want to use a JSP (the java code just used to get date, the rest are
html and javascript),
to display a table. the requirement is the...
|
by: Jim's wife |
last post by:
Hi all
I need to create a new table based on a source table.
The new table is almost the same as the source table in that just some field
names must change, and a few new fields added or...
|
by: Dabbler |
last post by:
is there a way to show the header even when GridView is empty? the page looks
kind of bare with just empydatatext or emptyrowtemplate.
Thanks.
|
by: jmarr02s |
last post by:
Hi,
How do I replace with when the field is empty?
Thanks!
jmarr02s
|
by: rczuba |
last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match.
I'm trying to create a payroll database for a small home business that I have that has had...
|
by: dixonjm |
last post by:
Hi,
I am adding a table dynamically using c# as below:-
productCell = new TableCell();
KSSCheckBox checkBox = new KSSCheckBox();
checkBox.ID = string.Format("CheckBox|{0}|{1}", x,...
|
by: billa856 |
last post by:
Hi,
I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx.
example
i have a table customer
CID CNAME CSALARY
1 Billa ...
|
by: =?Utf-8?B?RGFu?= |
last post by:
I am reposting a question from about 3 weeks ago ("sorting capability").
I have an aspx page in which I get the data from a database dynamically,
through C# code, by creating a dynamic table...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |