Avatar billede pizzamania Nybegynder
06. juli 2001 - 00:19 Der er 11 kommentarer og
1 løsning

<br> feature... ??

Could anyone please help me get this <br> feature:


function rep(this)
    this = Replace(this, \"\'\", \"\'\'\")
    rep = Replace(this, vbCrLf, \"<br>\")
end function


in this script:
PLEASE :-)



---::::---:::----:::---:::---::---:::---




<%@Language=VBScript %>

<%
if Session(\"Login\") <> true then
    Response.Redirect(\"default.asp?failure=not\")
end if
%>

<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->


<%

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strCategory, strTitle, strTeaser, strAuthor, strNews

    strCategory = Request.Form(\"Category\")
    strTitle = Request.Form(\"title\")
    strTeaser = Request.Form(\"teaser\")
    strAuthor = Request.Form(\"author\")
    strNews = Request.Form(\"news\")

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM News WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM News WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = strTitle
        rs(\"Category\") = strCategory
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"News\") = strNews
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"edit_other.asp\"

    End If



    If request(\"mode\") = \"edit\" Then

    strSQL = \"SELECT * FROM News WHERE id =\"& request(\"id\")
    SET rs = Conn.Execute( strSQL )

        strEditTitle = rs(\"Title\")
        strEditCategory = rs(\"Category\")
        strEditTeaser = rs(\"Teaser\")
        strEditAuthor = rs(\"Author\")
        strEditNews = rs(\"News\")

        rs.Close
    SET rs = Nothing

visInput = False

End IF

    If Request(\"mode\") = \"delete\" Then

    strSQL = \"DELETE FROM News WHERE id =\"& request(\"id\")
    Conn.Execute (strSQL)

    End If

%>


<HTML>
<HEAD>
<META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\">
</HEAD>
<BODY link=\"#003300\" vlink=\"#006600\" alink=\"#0000CC\">

<%
\'************************************* Start Lister Other

    Dim MyQuote
        MyQuote = Chr(34)


    strSQL = \"SELECT ID, Title, Category, Teaser FROM News WHERE Category = \'Other\' ORDER BY Dated DESC\"
    SET rs = Conn.Execute( strSQL )

Response.Write(\"<TABLE Width=\'500\' cellpadding=\'3\' Cellspacing=\'0\' Border=\'0\'>\")
Response.Write(\"<TR>\")
Response.Write(\"<TD colspan=\'4\'><B>\" & rs(\"Category\") & \":</B><br><br><br></TD>\")
Response.Write(\"</TR>\")
   

    do while not rs.eof
    on error resume next


Response.Write(\"<TR bgcolor=\'d9dceo\'>\")
Response.Write(\"<TD><B><A HREF=\'edit_other.asp?id=\" & rs(\"ID\") & \"&mode=delete\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to delete this news ?\');\" & MyQuote & \"><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#014A65\'>Delete</font></A></B></TD>\")
Response.Write(\"<TD><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#000000\'><b>\" & rs(\"Title\") & \"<b></font></TD>\")
Response.Write(\"<TD><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#000000\'>\" & rs(\"Teaser\") & \"</font></TD>\")
Response.Write(\"<TD><B><A HREF=\'edit_other_edit.asp?id=\" & rs(\"ID\") & \"&mode=edit\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to edit this news ?\');\" & MyQuote & \"><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#014A65\'>Edit</font></A></B></TD>\")
Response.Write(\"</TR>\")
Response.Write(\"<TR><TD colspan=\'4\'>&nbsp;</TD></TR>\")

    rs.movenext
    loop

Response.Write(\"</TABLE>\")

%>


<p> </p><br>
<TR><TD><a href=\"news_edit.asp\"><B><font face=\'verdana, arial, helvetica\' size=\'2\' color=\'#014A65\'>- BACK -</font></B></a></TD></TR>
<br>
</BODY>
</HTML>
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 00:22 #1
The way you\'re doing it right now, replacing \' with \'\' is not neccesarry.

The other thing with <br> can be used like this:

Rs(\"category\") = Replace(strCategory, vbCrLf, \"<br>\")

Just an example
Avatar billede pizzamania Nybegynder
06. juli 2001 - 00:32 #2
So, could you put that into the script I got there ?

må jeg lage en:
Rs(\"category\") = Replace(strCategory, vbCrLf, \"<br>\")
for hver av de \"Teaser, News etc. som det skal brukes på ?
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 00:36 #3
Like this:
I\'ve put it in a function:

<%@Language=VBScript %>

<%
if Session(\"Login\") <> true then
    Response.Redirect(\"default.asp?failure=not\")
end if
%>

<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->

function fixstr(st)
    fixstr = replace(st, vbCrLf, \"<br>\")
end function

<%

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strCategory, strTitle, strTeaser, strAuthor, strNews

    strCategory = Request.Form(\"Category\")
    strTitle = Request.Form(\"title\")
    strTeaser = Request.Form(\"teaser\")
    strAuthor = Request.Form(\"author\")
    strNews = Request.Form(\"news\")

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM News WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM News WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = fixstr(strTitle)
        rs(\"Category\") = fixstr(strCategory)
        rs(\"Teaser\") = fixstr(strTeaser)
        rs(\"Author\") = fixstr(strAuthor)
        rs(\"News\") = fixstr(strNews)
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"edit_other.asp\"

    End If



    If request(\"mode\") = \"edit\" Then

    strSQL = \"SELECT * FROM News WHERE id =\"& request(\"id\")
    SET rs = Conn.Execute( strSQL )

        strEditTitle = rs(\"Title\")
        strEditCategory = rs(\"Category\")
        strEditTeaser = rs(\"Teaser\")
        strEditAuthor = rs(\"Author\")
        strEditNews = rs(\"News\")

        rs.Close
    SET rs = Nothing

visInput = False

End IF

    If Request(\"mode\") = \"delete\" Then

    strSQL = \"DELETE FROM News WHERE id =\"& request(\"id\")
    Conn.Execute (strSQL)

    End If

%>


<HTML>
<HEAD>
<META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\">
</HEAD>
<BODY link=\"#003300\" vlink=\"#006600\" alink=\"#0000CC\">

<%
\'************************************* Start Lister Other

    Dim MyQuote
        MyQuote = Chr(34)


    strSQL = \"SELECT ID, Title, Category, Teaser FROM News WHERE Category = \'Other\' ORDER BY Dated DESC\"
    SET rs = Conn.Execute( strSQL )

Response.Write(\"<TABLE Width=\'500\' cellpadding=\'3\' Cellspacing=\'0\' Border=\'0\'>\")
Response.Write(\"<TR>\")
Response.Write(\"<TD colspan=\'4\'><B>\" & rs(\"Category\") & \":</B><br><br><br></TD>\")
Response.Write(\"</TR>\")
   

    do while not rs.eof
    on error resume next


Response.Write(\"<TR bgcolor=\'d9dceo\'>\")
Response.Write(\"<TD><B><A HREF=\'edit_other.asp?id=\" & rs(\"ID\") & \"&mode=delete\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to delete this news ?\');\" & MyQuote & \"><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#014A65\'>Delete</font></A></B></TD>\")
Response.Write(\"<TD><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#000000\'><b>\" & rs(\"Title\") & \"<b></font></TD>\")
Response.Write(\"<TD><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#000000\'>\" & rs(\"Teaser\") & \"</font></TD>\")
Response.Write(\"<TD><B><A HREF=\'edit_other_edit.asp?id=\" & rs(\"ID\") & \"&mode=edit\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to edit this news ?\');\" & MyQuote & \"><font face=\'verdana, arial, helvetica\' size=\'1\' color=\'#014A65\'>Edit</font></A></B></TD>\")
Response.Write(\"</TR>\")
Response.Write(\"<TR><TD colspan=\'4\'>&nbsp;</TD></TR>\")

    rs.movenext
    loop

Response.Write(\"</TABLE>\")

%>


<p> </p><br>
<TR><TD><a href=\"news_edit.asp\"><B><font face=\'verdana, arial, helvetica\' size=\'2\' color=\'#014A65\'>- BACK -</font></B></a></TD></TR>
<br>
</BODY>
</HTML>
Avatar billede pizzamania Nybegynder
06. juli 2001 - 01:00 #4
Er ikke dette rett ?


<%@Language=VBScript %>

<%
if Session(\"Login\") <> true then
    Response.Redirect(\"http://www.ontheminute.com/news/admin/default.asp?failure=not\")
end if
%>


<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->

function fixstr(st)
fixstr = replace(st, vbCrLf, \"<br>\")
end function

<%

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strTitle, strDate, strTeaser, strAuthor, strNews

    strTitle = Request.Form(\"title\")
    strDate = Request.Form(\"Date\")
    strTeaser = Request.Form(\"teaser\")
    strAuthor = Request.Form(\"author\")
    strColumn = Request.Form(\"Column\")

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM Column WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = strTitle
        rs(\"Date\") = strDate
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"Column\") = strColumn
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"column_hakon.asp\"

    End If



    If request(\"mode\") = \"edit\" Then

    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
    SET rs = Conn.Execute( strSQL )

        strEditTitle = rs(\"Title\")
        strEditDate = rs(\"Date\")
        strEditTeaser = rs(\"Teaser\")
        strEditAuthor = rs(\"Author\")
        strEditColumn = rs(\"Column\")

        rs.Close
    SET rs = Nothing

visInput = False

End IF

    If Request(\"mode\") = \"delete\" Then

    strSQL = \"DELETE FROM Column WHERE id =\"& request(\"id\")
    Conn.Execute (strSQL)

    End If

%>


<HTML>
<HEAD>
<META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\">
</HEAD>
<BODY link=\"#003300\" vlink=\"#006600\" alink=\"#0000CC\">

<form action=\'column_hakon.asp?mode=add&id=<%=request(\"id\")%>\' method=\'post\' name=\"FrmNews\">


  <p><b>Håkon Høyland  -  Columns</b></p><br>


  <p>


<b>Date</b><br>
Must be in this format: <b>Sunday, April 8, 2001</b><br>
<input type=\'text\' size=\'20\' name=\'date\' Value=\"<% if Not visInput then Response.Write strEditDate end if %>\">
<p>

<b>Title</b><br>
<input type=\'text\' size=\'40\' name=\'title\' Value=\"<% if Not visInput then Response.Write strEditTitle end if %>\">
<p>
<b>Teaser</b><br>
Should not be more than 25 words or 110 letters !!<br>
<textarea rows=\'5\' cols=\'50\' name=\'teaser\'><% if Not visInput then Response.Write strEditTeaser end if %></textarea>
<p>
<b>Column</b><br>
<textarea rows=\'15\' cols=\'60\' name=\'Column\'><% if Not visInput then Response.Write strEditColumn end if %></textarea>
  <p> <b>Author</b><br>
    <select name=\"author\" value=\"Håkon Høyland\">
<option value=\"Håkon Høyland\">Håkon Høyland</option>
    </select>
<p>
<input type=\'submit\' value=\'Add your Column\' onClick=\"return BekreftInsert();\">
</form>



<br><br>
<br>

<%
\'************************************* Start Lister Håkon Høyland\'s artikler
    Dim MyQuote
        MyQuote = Chr(34)


    strSQL = \"SELECT * FROM Column WHERE Author = \'Håkon Høyland\' ORDER BY ID\"
    SET rs = Conn.Execute( strSQL )

Response.Write(\"<TABLE Width=\'500\' cellpadding=\'3\' Cellspacing=\'0\' Border=\'0\'>\")   

Response.Write(\"<TR>\")
Response.Write(\"<TD colspan=\'4\'><B>Previous columns written by \" & rs(\"Author\") & \":</B><br><br></TD>\")
Response.Write(\"</TR>\")

    do while not rs.eof
    on error resume next

Response.Write(\"<TR bgcolor=\'d9dceo\'>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=delete\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Delete this previous written column ? (should not be done)\');\" & MyQuote & \">Delete</A></B></TD>\")
Response.Write(\"<TD>\" & rs(\"Title\") & \"</TD>\")
Response.Write(\"<TD>\" & rs(\"Teaser\") & \"</TD>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=edit&formAction=edit\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Edit this previous written column ?\');\" & MyQuote & \">Edit</A></B></TD>\")
Response.Write(\"</TR>\")
Response.Write(\"<TR><TD colspan=\'4\'>&nbsp;</TD></TR>\")

    rs.movenext
    loop

Response.Write(\"</TABLE>\")
\'************************************* Slutt Lister Håkon Høyland\'s artikler

%>

<br><br>
<TR><TD><a href=\"column_menu.asp\"><B><font face=\'verdana, arial, helvetica\' size=\'2\' color=\'#014A65\'>- Main Column Menu -</font></B></a></TD></TR>
<br>

</BODY>
</HTML>



--:::___::::____:::::::::__________

Det virker ikke. Hva er galt ?
Avatar billede pizzamania Nybegynder
06. juli 2001 - 01:13 #5
It doesnt work ??
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 01:18 #6
Sorry .. I inserted the function outside of the ASP... here it is:

<%@Language=VBScript %>

<%
if Session(\"Login\") <> true then
    Response.Redirect(\"http://www.ontheminute.com/news/admin/default.asp?failure=not\")
end if
%>


<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->

<%

function fixstr(st)
  fixstr = replace(st, vbCrLf, \"<br>\")
end function

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strTitle, strDate, strTeaser, strAuthor, strNews

    strTitle = Request.Form(\"title\")
    strDate = Request.Form(\"Date\")
    strTeaser = Request.Form(\"teaser\")
    strAuthor = Request.Form(\"author\")
    strColumn = Request.Form(\"Column\")

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM Column WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = strTitle
        rs(\"Date\") = strDate
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"Column\") = strColumn
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"column_hakon.asp\"

    End If



    If request(\"mode\") = \"edit\" Then

    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
    SET rs = Conn.Execute( strSQL )

        strEditTitle = rs(\"Title\")
        strEditDate = rs(\"Date\")
        strEditTeaser = rs(\"Teaser\")
        strEditAuthor = rs(\"Author\")
        strEditColumn = rs(\"Column\")

        rs.Close
    SET rs = Nothing

visInput = False

End IF

    If Request(\"mode\") = \"delete\" Then

    strSQL = \"DELETE FROM Column WHERE id =\"& request(\"id\")
    Conn.Execute (strSQL)

    End If

%>


<HTML>
<HEAD>
<META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\">
</HEAD>
<BODY link=\"#003300\" vlink=\"#006600\" alink=\"#0000CC\">

<form action=\'column_hakon.asp?mode=add&id=<%=request(\"id\")%>\' method=\'post\' name=\"FrmNews\">


  <p><b>Håkon Høyland  -  Columns</b></p><br>


  <p>


<b>Date</b><br>
Must be in this format: <b>Sunday, April 8, 2001</b><br>
<input type=\'text\' size=\'20\' name=\'date\' Value=\"<% if Not visInput then Response.Write strEditDate end if %>\">
<p>

<b>Title</b><br>
<input type=\'text\' size=\'40\' name=\'title\' Value=\"<% if Not visInput then Response.Write strEditTitle end if %>\">
<p>
<b>Teaser</b><br>
Should not be more than 25 words or 110 letters !!<br>
<textarea rows=\'5\' cols=\'50\' name=\'teaser\'><% if Not visInput then Response.Write strEditTeaser end if %></textarea>
<p>
<b>Column</b><br>
<textarea rows=\'15\' cols=\'60\' name=\'Column\'><% if Not visInput then Response.Write strEditColumn end if %></textarea>
  <p> <b>Author</b><br>
    <select name=\"author\" value=\"Håkon Høyland\">
<option value=\"Håkon Høyland\">Håkon Høyland</option>
    </select>
<p>
<input type=\'submit\' value=\'Add your Column\' onClick=\"return BekreftInsert();\">
</form>



<br><br>
<br>

<%
\'************************************* Start Lister Håkon Høyland\'s artikler
    Dim MyQuote
        MyQuote = Chr(34)


    strSQL = \"SELECT * FROM Column WHERE Author = \'Håkon Høyland\' ORDER BY ID\"
    SET rs = Conn.Execute( strSQL )

Response.Write(\"<TABLE Width=\'500\' cellpadding=\'3\' Cellspacing=\'0\' Border=\'0\'>\")   

Response.Write(\"<TR>\")
Response.Write(\"<TD colspan=\'4\'><B>Previous columns written by \" & rs(\"Author\") & \":</B><br><br></TD>\")
Response.Write(\"</TR>\")

    do while not rs.eof
    on error resume next

Response.Write(\"<TR bgcolor=\'d9dceo\'>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=delete\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Delete this previous written column ? (should not be done)\');\" & MyQuote & \">Delete</A></B></TD>\")
Response.Write(\"<TD>\" & rs(\"Title\") & \"</TD>\")
Response.Write(\"<TD>\" & rs(\"Teaser\") & \"</TD>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=edit&formAction=edit\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Edit this previous written column ?\');\" & MyQuote & \">Edit</A></B></TD>\")
Response.Write(\"</TR>\")
Response.Write(\"<TR><TD colspan=\'4\'>&nbsp;</TD></TR>\")

    rs.movenext
    loop

Response.Write(\"</TABLE>\")
\'************************************* Slutt Lister Håkon Høyland\'s artikler

%>

<br><br>
<TR><TD><a href=\"column_menu.asp\"><B><font face=\'verdana, arial, helvetica\' size=\'2\' color=\'#014A65\'>- Main Column Menu -</font></B></a></TD></TR>
<br>

</BODY>
</HTML>
Avatar billede pizzamania Nybegynder
06. juli 2001 - 01:38 #7
It still doesnt make automaticly <br>.. ???  it still doesnt work as it should. r u sure its the right code to put in ?
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 14:22 #8
It replaces linebreaks (vbCrLf) with <br>\'s, and it works. I\'ve used it thousands of times before myself!

It doesn\'t make linebreaks automatically, it makes linebreaks where YOU\'VE made a linebeak in the text.
Avatar billede pizzamania Nybegynder
06. juli 2001 - 17:51 #9
check it out: http://tv.ordigno.com/tst/database/viewcolumn.asp?id=26

here I have:
j k j k j k j

In the form here:
http://tv.ordigno.com/tst/database/column_hakon.asp

I have pressed ENTER for <br> but they dont come ?

What might be wrong, I have tried the form you sent me, have you tried.. ?

BTW,Håkon told me that he knows who you are, do you know him ?
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 18:59 #10
I know Håkon, yes ... I have him on ICQ.
It seems like you don\'t use the function where it\'s supposed to be used.
This is what I got from a View Source on the adress you wrote:

k


j


k


j

k

j

You should put a fixstr() around every string in this block: (under if .. = \"add\" then)

        rs(\"Title\") = strTitle
        rs(\"Date\") = strDate
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"Column\") = strColumn
Avatar billede pizzamania Nybegynder
06. juli 2001 - 20:44 #11
This is what I use now, is something wrong with it ?


<%@Language=VBScript %>




<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->



<%

function fixstr(st)
fixstr = replace(st, vbCrLf, \"<br>\")
end function

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strTitle, strDate, strTeaser, strAuthor, strNews

    strTitle = Request.Form(\"title\")
    strDate = Request.Form(\"Date\")
    strTeaser = Request.Form(\"teaser\")
    strAuthor = Request.Form(\"author\")
    strColumn = Request.Form(\"Column\")

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM Column WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = strTitle
        rs(\"Date\") = strDate
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"Column\") = strColumn
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"column_hakon.asp\"

    End If



    If request(\"mode\") = \"edit\" Then

    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
    SET rs = Conn.Execute( strSQL )

        strEditTitle = rs(\"Title\")
        strEditDate = rs(\"Date\")
        strEditTeaser = rs(\"Teaser\")
        strEditAuthor = rs(\"Author\")
        strEditColumn = rs(\"Column\")

        rs.Close
    SET rs = Nothing

visInput = False

End IF

    If Request(\"mode\") = \"delete\" Then

    strSQL = \"DELETE FROM Column WHERE id =\"& request(\"id\")
    Conn.Execute (strSQL)

    End If

%>


<HTML>
<HEAD>
<META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\">
</HEAD>
<BODY link=\"#003300\" vlink=\"#006600\" alink=\"#0000CC\">

<form action=\'column_hakon.asp?mode=add&id=<%=request(\"id\")%>\' method=\'post\' name=\"FrmNews\">


  <p><b>Håkon Høyland  -  Columns</b></p><br>


  <p>


<b>Date</b><br>
Must be in this format: <b>Sunday, April 8, 2001</b><br>
<input type=\'text\' size=\'20\' name=\'date\' Value=\"<% if Not visInput then Response.Write strEditDate end if %>\">
<p>

<b>Title</b><br>
<input type=\'text\' size=\'40\' name=\'title\' Value=\"<% if Not visInput then Response.Write strEditTitle end if %>\">
<p>
<b>Teaser</b><br>
Should not be more than 25 words or 110 letters !!<br>
<textarea rows=\'5\' cols=\'50\' name=\'teaser\'><% if Not visInput then Response.Write strEditTeaser end if %></textarea>
<p>
<b>Column</b><br>
<textarea rows=\'15\' cols=\'60\' name=\'Column\'><% if Not visInput then Response.Write strEditColumn end if %></textarea>
  <p> <b>Author</b><br>
    <select name=\"author\" value=\"Håkon Høyland\">
<option value=\"Håkon Høyland\">Håkon Høyland</option>
    </select>
<p>
<input type=\'submit\' value=\'Add your Column\' onClick=\"return BekreftInsert();\">
</form>



<br><br>
<br>

<%
\'************************************* Start Lister Håkon Høyland\'s artikler
    Dim MyQuote
        MyQuote = Chr(34)


    strSQL = \"SELECT * FROM Column WHERE Author = \'Håkon Høyland\' ORDER BY ID\"
    SET rs = Conn.Execute( strSQL )

Response.Write(\"<TABLE Width=\'500\' cellpadding=\'3\' Cellspacing=\'0\' Border=\'0\'>\")   

Response.Write(\"<TR>\")
Response.Write(\"<TD colspan=\'4\'><B>Previous columns written by \" & rs(\"Author\") & \":</B><br><br></TD>\")
Response.Write(\"</TR>\")

    do while not rs.eof
    on error resume next

Response.Write(\"<TR bgcolor=\'d9dceo\'>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=delete\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Delete this previous written column ? (should not be done)\');\" & MyQuote & \">Delete</A></B></TD>\")
Response.Write(\"<TD>\" & rs(\"Title\") & \"</TD>\")
Response.Write(\"<TD>\" & rs(\"Teaser\") & \"</TD>\")
Response.Write(\"<TD><B><A HREF=\'column_hakon.asp?id=\" & rs(\"ID\") & \"&mode=edit&formAction=edit\' \" & \"onClick=\" & MyQuote & \"return confirm(\'Are you sure you want to Edit this previous written column ?\');\" & MyQuote & \">Edit</A></B></TD>\")
Response.Write(\"</TR>\")
Response.Write(\"<TR><TD colspan=\'4\'>&nbsp;</TD></TR>\")

    rs.movenext
    loop

Response.Write(\"</TABLE>\")
\'************************************* Slutt Lister Håkon Høyland\'s artikler

%>

<br><br>
<TR><TD><a href=\"column_menu.asp\"><B><font face=\'verdana, arial, helvetica\' size=\'2\' color=\'#014A65\'>- Main Column Menu -</font></B></a></TD></TR>
<br>

</BODY>
</HTML>
Avatar billede tdaugaard Nybegynder
06. juli 2001 - 21:54 #12
I told you that you need to put fixstr() around every variable name that you want to replace linebreaks with <br>\'s in.

Like below. This is some of the script from the top ...

<%@Language=VBScript %>

<!-- #Include file=\"adovbs.inc\" -->
<!-- #Include file=\"dsnAcces.asp\" -->

<%

function fixstr(st)
fixstr = replace(st, vbCrLf, \"<br>\")
end function

    id = Request.QueryString(\"id\")
    mode = Request.QueryString(\"mode\")

    If mode = \"add\" Then

\'***************************************************************************************   
\'***************************************************************************************   
    Dim rsNews, strSQL, strTitle, strDate, strTeaser, strAuthor, strNews

    strTitle = fixstr(Request.Form(\"title\"))
    strDate = fixstr(Request.Form(\"Date\"))
    strTeaser = fixstr(Request.Form(\"teaser\"))
    strAuthor = fixstr(Request.Form(\"author\"))
    strColumn = fixstr(Request.Form(\"Column\"))

    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
        If id = \"\" Then
    strSQL = \"SELECT * FROM Column WHERE (ID = 0)\"
        Else
    strSQL = \"SELECT * FROM Column WHERE id =\"& request(\"id\")
        End If

        rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

        If (rs.BOF Or rs.EOF) Then
        rs.AddNew
        End If
        rs(\"Title\") = strTitle
        rs(\"Date\") = strDate
        rs(\"Teaser\") = strTeaser
        rs(\"Author\") = strAuthor
        rs(\"Column\") = strColumn
        rs.Update

        rs.Close
    Set rs = Nothing

    Response.Redirect \"column_hakon.asp\"

    End If
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester