Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global ASA 2

Status
Not open for further replies.

jojo79

Programmer
Oct 11, 2006
40
US
I have a global file that capture how many user are on my site. I am trying to display that. But i want the grammar to be correct, so I am trying to write the following.
If there is only 1 user on, i want it to say "Currently 1 Visitor", but if there are more then 1 I want to write "Currently 4 Visitors". I want visitor to be plural, Thanks for any help.

Code:
<%
if (Application("SessionCount") < 1) 
{
document.write("Currently" +(Application("SessionCount")) "Vistitor" )
}
else
{
document.write("Currently" +(Application("SessionCount")) "Vistitors" )
}
%>
 
I have had some progress in my quest, this one display the results = "Currently 1 Visitors"
which is wrong it should say "Currently 1 Visitor" because their is only 1 visitor, not 1 visitors....


Code:
<%

If Application("SessionCount") > 1 Then
Response.Write "Currently "  & Application("SessionCount") & " Visitor"
else 
Response.Write "Currently "  & Application("SessionCount") & " Visitors"
end if
%></div></td>
 
try using CInt()

If CInt(Application("SessionCount")) > 1 then

-DNG
 
You have your If statement backwards. basically it says right now:
If there is more than one visitor Then
Output "Visitor"
Else (if there is one or fewer)
Output "Visitors"
End If

Even after you switch it, your still going to run into an issue with 0 vs 1. You might be better off doing this:
Code:
Response.Write "Currently " & Applicaiton("SessionCount") & " Visitor"
If Application("SessionCount") <> 1 Then Response.Write "s"
This way it outputs "Visitor" and then if it is any number but 1, adds the "s" on the end.

-T

 
I thank you both, I had to combind both codes to get it to work, Thank you very much, I hope I can return the favor one day.

Final
Code:
Response.Write "Currently " & CInt(Application("SessionCount"))  & " Visitor"
If CInt(Application("SessionCount"))  <> 1 Then Response.Write "s"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top