Click to See Complete Forum and Search --> : Writing an ASP Function
jjr0319
03-14-2006, 10:44 AM
im trying to write a function that will display text based upon a number stored in my access database as text. i can figure out what im doing wrong. here's my ASP code:
<% Dim Fact, FactNum
FUNCTION Fact(FactNum)
If FactNum="4" Then
FactNum="Excellent"
End If
End FUNCTION
%>
and here's my HTML code to display the RS:
<td align="center"><b><%= Fact(Fact1A) %></b></td>
FYI: Fact1A in my database is definitely a 4.
thanks in advance for the help
Try:
Instead of:
FactNum="Excellent"
Use:
Fact="Excellent"
Alternatively, check that your 4 is 4 instead of "4":
Instead of:
If FactNum="4" Then
Use:
If FactNum+0=4 Then
jjr0319
03-14-2006, 02:00 PM
nope, neither of those will work. if i write an IF statment, instead of using a function, it works:
If Fact1A=4 Then
Fact1A="Excellent"
End If
but i have multiple Fact1X's in my database, and creating multiple if's statements seems redundant.
can anyone help?
and here's my HTML code to display the RS:
<td align="center"><b><%= Fact(Fact1A) %></b></td>
Change to the following:
<td align="center"><b><%= Fact(objRS("Fact1A")) %></b></td>
Make sure you change objRS to whatever the recordset name is.
jjr0319
03-15-2006, 09:00 AM
thanks for the help. i got it working:
Function Fact(FactNum)
If FactNum=4 Then
Fact="Excellent"
End If
End Function
<td align="center"><b><%=Fact(Fact1A)%></b></td>
i think it wasnt working before becasue i had the function after the RS was getting called. once i move the code above it, it worked.
thanks to both of you for the help.