Trevor said:
Sorry about that.
Time for me do the testing
IGBTY (I'll get back to you)
Yes, well, the behaviour you saw is because display_no() was read as HTML
whereas it should be a call to JS, i.e. it doesn't belong there.
My mistake for not thinking it through and testing before I posted.
I thought of a couple of solutions
One is to just the add the text " items" after the database field
e.g. change <td valign="top"><%=FP_FieldVal(fp_rs,"item_count")%></td>
to <td valign="top"><%=FP_FieldVal(fp_rs,"item_count")%> items</td>
This doesn't test for only one item, so this will read "1 items" when the
item count is 1
The other is to alter the VBScript function FP_FieldVal to add the text
"item" or " items"
This is the function in fpdblib
Function FP_FieldVal(rs, fldname)
FP_FieldVal = FP_HTMLEncode(FP_Field(rs, fldname))
if FP_FieldVal = "" then FP_FieldVal = " "
End Function
Change it to
Function FP_FieldVal(rs, fldname)
FP_FieldVal = FP_HTMLEncode(FP_Field(rs, fldname)) & " items"
if FP_FieldVal = "" then FP_FieldVal = " "
End Function
This needs a bit of fine tuning
1. You only want to use it when the field is item_count (or whatever)
So try
Function FP_FieldVal(rs, fldname)
FP_FieldVal = FP_HTMLEncode(FP_Field(rs, fldname))
if fldname = "item_count" then
FP_FieldVal = FP_FieldVal + " items"
end if
if FP_FieldVal = "" then FP_FieldVal = " "
End Function
2. You want to test for item_count = 1
So try
Function FP_FieldVal(rs, fldname)
FP_FieldVal = FP_HTMLEncode(FP_Field(rs, fldname))
if fldname = "item_count" then
if FP_FieldVal = "1" then
FP_FieldVal = FP_FieldVal + " item"
else
FP_FieldVal = FP_FieldVal + " items"
end if
end if
if FP_FieldVal = "" then FP_FieldVal = " "
End Function
This has a problem in that item_count is probably numeric, so the test if
FP_FieldVal = "1" will fail with a field type mismatch error
So try
Function FP_FieldVal(rs, fldname)
FP_FieldVal = FP_HTMLEncode(FP_Field(rs, fldname))
if fldname = "item_count" then
if CStr(FP_FieldVal) = "1" then
FP_FieldVal = FP_FieldVal + " item"
else
FP_FieldVal = FP_FieldVal + " items"
end if
end if
if FP_FieldVal = "" then FP_FieldVal = " "
End Function
I haven't tested this because the fields I am trying to test against are
all character to start with.
I still think a JS solution would work, but if you can get this to work,
then let's leave well enough alone
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website:
http://trevorl.mvps.org/