Quote:
Originally Posted by petvampire
...
I want to post the smiles where the <%=(chatmsg.Fields.Item("TBLmessage").Value)%> is as this displays the message. Any ideas how i go about doing this as the chat does not have any filter yet. thanks in advance.
Hi Vamp, and welcome to Bytes.
A couple things before I get into your question: first, we use code tags to make our posts more readable, [ code ] code goes here [ /code ] (remove the spaces to see how it works), please do the same in the future. Second, the longhand you have used for pulling up the field value is very long. The following two lines are equivalent:
- <%=(chatmsg.Fields.Item("TBLmessage").Value)%>
-
<%=chatmsg("TBLmessage")%>
Hopefully if you figure that out now it will make your future coding a little easier.
So to make sure I understand you, when you response.write chatmsg("TBLmessage") you might get someting like this:
and you want the script to replace the last two characters with a smilie graphic, right?
The code to make the replacement is going to look something like this:
- <%=replace(chatmsg("TBLmessage"), ":)", "<img src='smile1.gif'>")%>
Does this make sense? Now depending on the number of smileys you want to recognize you might want to make this significantly more complicated, maybe put the replace statement in a loop in a separate function call (and now my mind is going blank on how you write functions in ASP, something like this):
- function smilify(chatText)
-
dim smileys(10)
-
dim smileyGraphics(10)
-
smileys(0) = ":)"
-
smileys(1) = ":S"
-
smileys(2) = ";)"
-
'...
-
smileyGraphics(0) = "<img src='smiley0.gif'>"
-
smileyGraphics(1) = "<img src='smiley1.gif'>"
-
smileyGraphics(2) = "<img src='smiley2.gif'>"
-
'...
-
-
dim fixedText
-
for x = 0 to 9
-
fixedText = replace(chatText, smileys(x), smileyGraphics(x))
-
next
-
-
response.write fixed text
-
end function
-
-
'...
-
-
smilify(chatmsg("TBLmessage"))
-
Of course you can get much fancier by keeping your smileys in a db or something, but this should work for your app. Let me know if this helps.
Jared