R Rinaldo Medlem sedan mars 2001 4 214 inlägg Frågan 3 okt. 2001 20:16 #1 Denna kod kastar ut inlägg från tabellen den ligger i när jag använder funktionen redigeraText.
Den gör bara detta i response.write och inte vanligt i början...
<!-- #INCLUDE FILE="adovbs.inc" -->
<!-- #INCLUDE FILE="connect.asp" -->
<HTML>
<HEAD>
<!-- #INCLUDE FILE="head.asp" -->
</HEAD>
<BODY >
<!-- #INCLUDE FILE="meny.asp" -->
<%SQL = "Select * From rubriker WHERE rubrikID = " & Request.QueryString("rubrikID") & " ORDER BY datum desc"
rs.open SQL, databas
Dim strText, iLength, iPos1, iPos2, iWordLength
Function redigeraText(strText) 'funktion för att att redigera text mot HTML och radbrytningar och långa ord
iPos1 = 1
iPos2 = 1
iWordLength = 0
strText = Trim(strText)
Do Until iPos2 = Len(strText)
iPos2 = iPos2 + 1
iWordLength = iWordLength + 1
If Mid(strText,iPos2,1) = " " Then
iWordLength = 0
End if
If iWordLength > 60 Then
strText = Mid(strText,1,iPos1-1)_
& Mid(strText,iPos1,iPos2-iPos1)_
& " " & Mid(strText,iPos2,Len(strText)-iPos2+1)
iPos1 = iPos2
iPos2 = iPos2 + 1
iWordLength = 0
End If
Loop
strText = Replace(Server.HTMLEncode(strText), vbcrlf, "<br>" & vbcrlf)
Response.Write strText
End Function
meddelande = rs("meddelande")
%>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="500" BGCOLOR="#999999"><TR><TD>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="500">
<TR>
<TD WIDTH="40" valign="top" bgcolor="#999999">
<IMG SRC="bilder/<%=rs("ikon")%>.gif">
</TD>
<TD WIDTH="600" bgcolor="#999999">
<b><%=(rs("rubrik"))%></b>
</TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="500">
<TR>
<TD WIDTH="170" valign="top" BGCOLOR="#CCCCCC"><BR>
<B>
<%response.write "<A HREF='visamedlem.asp?visamedlem=ja&medlem="&rs("namn")&"' CLASS=link>" & redigeraText(left(rs("namn"),20)) & "</A><BR>"%>
<%=rs("datum")%><BR><BR>
Antal svar: <%=rs("antalsvar")%></B>
</TD>
<TD WIDTH="470" BGCOLOR="#CCCCCC">
<%=redigeraText(meddelande)%>
</TD>
</TR>
</TABLE>
</TD></TR></TABLE><BR><BR>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="500" BGCOLOR="#999999"><TR><TD>Svar till inlägget </TD></TR><TR><TD>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="5" WIDTH="500">
<%
rs.close
mypage = Request("whichpage")
If mypage = "" then
mypage = 1
End If
mypagesize = 10
SQL = "Select * From svar WHERE svartill = " & Request.QueryString("rubrikID") & " ORDER BY datum desc"
rs.cursorlocation = 3
rs.cachesize = 5
rs.open SQL,Databas
If rs.EOF then
Response.write " </TD></TR></TABLE></TD></TR></TABLE><TABLE><TR><TD>Inga svar för tillfället</TD></TR></TABLE> " & sok
Else
rs.movefirst
rs.pagesize = mypagesize
maxcount = Cint(rs.pagecount)
rs.absolutepage = mypage
howmanyrecs = 0
howmanyfields = rs.fields.count -1
Do While Not rs.EOF AND howmanyrecs < rs.pagesize
counter = counter + 1
If counter mod 2 = 0 then
color = "#CCCCCC"
Else
color = "#EEEEEE"
End If
svar = rs("svar")
Response.write "<TR BGCOLOR='" & color & "'><TD WIDTH=170 valign=top><img src=bilder/"&rs("ikon")&".gif ALIGN=left><B><A HREF='visamedlem.asp?visamedlem=ja&medlem="&rs("namn")&"' CLASS=link>" & left(rs("namn"),20) & "</A><BR>" & rs("datum") & "</B></TD>[b]<TD WIDTH=470>"& redigeraText(svar) &"</TD>[/b]</TR>"
rs.movenext
howmanyrecs = howmanyrecs + 1
Loop
rs.close
Set rs = nothing
response.write "</TABLE></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH=500><TR><TD ALIGN=RIGHT>"
If maxcount <> 0 then
response.write "<B>sida " & mypage & " av " & maxcount & " </B>" & sidor:
pad = "0"
scriptname = request.Servervariables("script_name")
for counter = 1 to maxcount
If counter >= 40 then
pad = ""
End If
ref = "| <a href='" & scriptname & "?rubrikID="& request.querystring("rubrikID")&"&whichpage=" & counter & "&pagesize=" & mypagesize & "' class=link>sida " & pad & counter & "</a> "
response.write ref & " "
if counter mod 40 = 0 then
response.write ""
End If
Next
End If
End If
%>
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>
<%databas.close
set databas = nothing
%>
[Redigerat av Rinaldo den 03 okt 2001]
L LarsG Medlem sedan dec. 2000 12 464 inlägg Function redigeraText(strText) 'funktion för att att redigera text mot HTML och radbrytningar och långa ord
iPos1 = 1
iPos2 = 1
iWordLength = 0
strText = Trim(strText)
Do Until iPos2 = Len(strText)
iPos2 = iPos2 + 1
iWordLength = iWordLength + 1
If Mid(strText,iPos2,1) = " " Then
iWordLength = 0
End if
If iWordLength > 60 Then
strText = Mid(strText,1,iPos1-1)_
& Mid(strText,iPos1,iPos2-iPos1)_
& " " & Mid(strText,iPos2,Len(strText)-iPos2+1)
iPos1 = iPos2
iPos2 = iPos2 + 1
iWordLength = 0
End If
Loop
strText = Replace(Server.HTMLEncode(strText), vbcrlf, "<br>" & vbcrlf)
[b]redigeraText = strText[/b]
End Function
Använd inte globala variabler i funktionen utan lägg dom lokalt.
------------------
essentitia preter non sans multiplicandum
R Rinaldo Medlem sedan mars 2001 4 214 inlägg Kanske byter ämne men finns det någon funktion som gör om http:// till länkar och kan man baka in det i denna?
L LarsG Medlem sedan dec. 2000 12 464 inlägg http://script.webforum.nu/wf/Forum1/HTML/000093.html
------------------
essentitia preter non sans multiplicandum
R Rinaldo Medlem sedan mars 2001 4 214 inlägg :oo
[Redigerat av Rinaldo den 04 okt 2001]
R Rinaldo Medlem sedan mars 2001 4 214 inlägg har ingen någon bra http funktion man kan få låna