Konverter enter i textarea til <br> før insert i DB
Hej...Jeg søger en metode til at konvertere entertegn i et textarea til <br> før indholdet lægges ned i accessdatabasen - der må altså ikke forekomme nogle \"huller\" i feltet i basen. Det skyldes at indholdet skal bruges til en javamenu og denne crasher hvis der forekommer \"huller\" i feltet i DB.
Her er koden:
<%@LANGUAGE=\"VBSCRIPT\"%><%
\' *** Insert Record: construct a sql insert statement and execute it
MM_editAction = CStr(Request(\"URL\"))
If (Request.QueryString <> \"\") Then
MM_editAction = MM_editAction & \"?\" & Request.QueryString
End If
If (CStr(Request(\"MM_insert\")) <> \"\") Then
MM_tableName = \"news\"
MM_fields = \"n_start,n_start,\',none,\'\',dato,dato,\',none,\'\',n_navn,n_navn,\',none,\'\',n_tag_nl,n_tag_nl,\',none,\'\',n_image1,n_image1,\',none,\'\',n_image2,n_image2,\',none,\'\',n_target,n_target,\',none,\'\',ni_start,ni_start,\',none,\'\',ni_dato,ni_dato,\',none,\'\',ni_navn,ni_navn,\',none,\'\',vigtig,vigtig,\',none,\'\',linknavn,linknavn,\',none,\'\',linktag_start,linktag_start,\',none,\'\',linktag_target,linktag_target,\',none,\'\',linktag_slut,linktag_slut,\',none,\'\',link,link,\',none,\'\',ni_tag_nl,ni_tag_nl,\',none,\'\',ni_image2,ni_image2,\',none,\'\',ni_target,ni_target,\',none,\'\'\"
MM_redirectPage = \"\"
\' create the insert sql statement
MM_tableValues = \"\"
MM_dbValues = \"\"
MM_fieldsArray = Split(MM_fields, \",\")
For i = LBound(MM_fieldsArray) To UBound(MM_fieldsArray) Step 5
FormVal = CStr(Request.Form(MM_fieldsArray(i)))
Delim = MM_fieldsArray(i+2)
If (Delim = \"none\") Then Delim = \"\"
AltVal = MM_fieldsArray(i+3)
If (AltVal = \"none\") Then AltVal = \"\"
EmptyVal = MM_fieldsArray(i+4)
If (EmptyVal = \"none\") Then EmptyVal = \"\"
If (FormVal = \"\") Then
FormVal = EmptyVal
Else
If (AltVal <> \"\") Then
FormVal = AltVal
ElseIf (Delim = \"\'\") Then \' escape quotes
FormVal = \"\'\" & Replace(FormVal,\"\'\",\"\'\'\") & \"\'\"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fieldsArray)) Then
MM_tableValues = MM_tableValues & \",\"
MM_dbValues = MM_dbValues & \",\"
End if
MM_tableValues = MM_tableValues & MM_fieldsArray(i+1)
MM_dbValues = MM_dbValues & FormVal
Next
MM_insertStr = \"insert into \" & MM_tableName & \" (\" & MM_tableValues & \") values (\" & MM_dbValues & \")\"
\' finish the sql and execute it
Set MM_insertCmd = Server.CreateObject(\"ADODB.Command\")
MM_insertCmd.ActiveConnection = \"dsn=data;\"
MM_insertCmd.CommandText = MM_insertStr
MM_insertCmd.Execute
\' redirect with URL parameters
If (MM_redirectPage = \"\") Then
MM_redirectPage = CStr(Request(\"URL\"))
End If
If (InStr(1, MM_redirectPage, \"?\", vbTextCompare) = 0 And (Request.QueryString <> \"\")) Then
MM_redirectPage = MM_redirectPage & \"?\" & Request.QueryString
End If
Call Response.Redirect(MM_redirectPage)
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body bgcolor=\"#FFFFFF\">
<h5>Indtast nyhed</h5>
<form name=\"form1\" method=\"post\" action=\"<%=MM_editAction%>\">
<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bordercolorlight=\"0\" bordercolordark=\"0\">
<tr>
<td>
<p><b> <b> </b> </b><b><b>
<input type=\"hidden\" name=\"n_start\" value=\"oFoldMenu.make(\'top\',\'\">
Nyhedsoverskrift:
<input type=\"hidden\" name=\"dato\" value=\"<%=Now%>\">
</b> </b></p>
</td>
<td><b><b><b>
<input type=\"text\" name=\"n_navn\" size=\"35\" maxlength=\"48\">
<input type=\"hidden\" name=\"n_tag_nl\" value=\"\',0,\">
<input type=\"hidden\" name=\"n_image1\" value=\"\'images/more_down.gif\',\">
<input type=\"hidden\" name=\"n_image2\" value=\"\'images/more_up.gif\');\">
<input type=\"hidden\" name=\"n_target\" value=\"0,\">
</b> </b></b></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<p><b> </b><b>
<input type=\"hidden\" name=\"ni_start\" value=\"oFoldMenu.make(\'sub\',\'\">
Nyhedsindhold:
<input type=\"hidden\" name=\"ni_dato\" value=\"<%=Date%>\">
</b></p>
</td>
<td><b>
<textarea name=\"ni_navn\" cols=\"100\"></textarea>
</b></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Vigtigt: </b></td>
<td>
<select name=\"vigtig\">
<option value=\"images/important_blank.gif\">Nej</option>
<option value=\"images/important.gif\">Ja</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Eventuelt billede: </b></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Eventuelt link: </b></td>
<td><b> Linknavn:
<input type=\"text\" name=\"linknavn\">
<input type=\"hidden\" name=\"linktag_start\" value=\"<a href="http://\">
<input type=\"hidden\" name=\"linktag_target\" value=\"" target="_blank">\">
<input type=\"hidden\" name=\"linktag_slut\" value=\"</a>\">
http//:
<input type=\"text\" name=\"link\" size=\"25\">
eller artikel:
<select name=\"select6\" onChange=\"link.value=this.value\">
<%
While (NOT rsartikler.EOF)
%>
<option value=\"<%=(rsartikler.Fields.Item(\"link\").Value)%>\"><%=(rsartikler.Fields.Item(\"overskrift\").Value)%></option>
<%
rsartikler.MoveNext()
Wend
%>
</select>
<input type=\"hidden\" name=\"ni_tag_nl\" value=\"\',0\">
<b> <b>
<input type=\"hidden\" name=\"ni_image2\" value=\"\',\'\');\">
</b> </b> <b>
<input type=\"hidden\" name=\"ni_target\" value=\",0,\'\">
<input type=\"submit\" name=\"Submit\" value=\"Opret nyhed\">
</b><b></b></b></td>
</tr>
<tr>
<td valign=\"top\"> </td>
<td> </td>
</tr>
</table>
<input type=\"hidden\" name=\"MM_insert\" value=\"true\">
</form>
</body>
</html>