Author |
Topic Search Topic Options
|
pablo_montiel
Newbie
Joined: 09 December 2004
Status: Offline
Points: 16
|
Post Options
Thanks(0)
Quote Reply
Topic: textarea from database Posted: 09 December 2004 at 5:23am |
Hi, I need some help to test how to retrieve data into the RTE_textarea.asp file from a database.
This example works:
strEditorContent = "<div style=""text-align: center; font-family: arial,helvetica,sans-serif;""> <h2>Welcome to Web Wiz Rich Text</h2> Free replacement WYSIWYG Editor for your textareas </div>"
But I need to retrieve data into the strEditorContent, from the field Text of my database.
This is working fine in the textarea for NON rich text editors (message_forma_inc.asp):
<%=Replace(Replace(Text,"&","&"),"<","<")%>
But, WHAT must I write to get the same effect in the RTE_textarea.asp ???
Edited by pablo_montiel - 09 December 2004 at 5:23am
|
|
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9791
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 7:54am |
Just display the data as you want it to be displayed in the text area
in the RTE_textarea.asp as if it where a normal web page. IE. between
the HTML <body> tags.
You can use the built in querystrings to pass across to the page which record to get from the database.
|
|
|
pablo_montiel
Newbie
Joined: 09 December 2004
Status: Offline
Points: 16
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 8:40am |
I have the following code in my default page, and it works fine with the NON rich text browser, Can you "more detail" explain me WHAT I should put in my RTE_textarea.asp to work ?
<!--#include file="RTE/includes/browser_page_encoding_inc.asp" -->
<%
'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")
If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0
If Request.Form("Action") <> "Post" Then
'--- Open set ---'
If (Requested <> 0) AND (Delete <> "True") Then
Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
ElseIf Requested = 0 Then
Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
Else
Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
Database.Close
Set Records = Nothing
Set Database = Nothing
Response.Redirect(SiteURL & PageName)
End If
If NOT Records.EOF Then
'--- Setup Variables ---'
RecordID = Records("RecordID")
Title = Records("Title")
Text = Records("Text")
End If
Records.Close
%>
<Form Name="frmAddMessage" Method="Post" onSubmit="document.getElementById('Submit').disabled=true;"& gt;
<input Name="Action" type="hidden" Value="Post">
<P><span id="Label1">Title : </span><input Name="Title" type="text" value="<%=Replace(Title,"""",""")%>" style="width:80%;" onChange="return setVarChange()"> </P>
<P>Content :<br>
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td class="td01" align="left">
<%
'Change this to the path to your RTE files
Const strPathToRTEFiles = "RTE/" 'This needs to hold the path to the RTE files
'The form name/id for the Web Wiz Rich Text (RTE) textarea is 'message'
%>
<!-- include the rich text editor -->
<!--#include file="RTE/RTE_editor_inc.asp" -->
</td>
</tr>
<tr>
<td colspan="2">
</tr>
</table>
</P>
|
|
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9791
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 10:56am |
You need to open the database in the RTE_textbox.asp file and read the data into that file.
The RTE editor can't use the normal text area, instead the text area is
actually an Iframe, what you are looking at is another page in an
Iframe with design mode enabled.
Look at it as if the RTE_textarea.asp another web page that simply opens in an Iframe.
|
|
|
pablo_montiel
Newbie
Joined: 09 December 2004
Status: Offline
Points: 16
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 12:35pm |
I am really a newbie an sorry about my insistence.
If I use this (at RTE_textarea.asp):
strEditorContent = "<div style=""text-align: center; font-family: arial,helvetica,sans-serif;""> <h2>Welcome to ...</h2></div>"
it works.-
But If I use:
strEditorContent = Replace(Replace(Text,"&","&"),"<","<")
it says that the Variable TEXT is not defined (that Replace: works fine in the message_forma_inc.asp file, but not in the RTE_textarea.asp ).
So the question is:
What must I write after: ""strEditorContent = "" or what must I write to retrieve data from the TEXT field so I could EDIT the RTE message I posted before into the database ?
Thanks in advance.
|
|
WebWiz-Bruce
Admin Group
Web Wiz Developer
Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9791
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 2:06pm |
This bit:-
--- Open set ---'
If (Requested <> 0) AND (Delete <> "True") Then
Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
ElseIf Requested = 0 Then
Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
Else
Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
Database.Close
Set Records = Nothing
Set Database = Nothing
Response.Redirect(SiteURL & PageName)
End If
If NOT Records.EOF Then
'--- Setup Variables ---'
RecordID = Records("RecordID")
Title = Records("Title")
Text = Records("Text")
End If |
needs to be in the RTE_textarea.asp, as the RTE_textarea.asp file is an
iframe it is a sepprate web page, so any variables used in this file
need to be declared in this file.
Look at RTE_textarea.asp as a sepprate file, you may find it easier
while sorting out the page to open the file RTE_textarea.asp in it's
own browser window.
Right click in your browser on the textrea in the RTE and select 'open frame in new window'.
|
|
|
pablo_montiel
Newbie
Joined: 09 December 2004
Status: Offline
Points: 16
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 3:43pm |
thanks! I think I am near the solution by now BUT, there is an error: Expected 'END' in this code of my RTE_textarea.asp
Do you know where the problem could be ??
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="includes/RTE_setup.asp" -->
<!--#include file="functions/RTE_functions_common.asp" -->
<%
'Set the response buffer to true as we maybe redirecting
Response.Buffer = True
'Make sure this page is not cached
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "No-Store"
Dim strEditorContent 'Holds the editors pre-filled content
Dim strQueryString1
Dim strQueryString2
Dim strQueryString3
strQueryString1 = Request.QueryString("QS1")
strQueryString2 = Request.QueryString("QS2")
strQueryString3 = Request.QueryString("QS3")
'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")
If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0
If Request.Form("Action") <> "Post" Then
'--- Open set ---'
If (Requested <> 0) AND (Delete <> "True") Then
Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
ElseIf Requested = 0 Then
Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
Else
Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
Database.Close
Set Records = Nothing
Set Database = Nothing
Response.Redirect(SiteURL & PageName)
End If
If NOT Records.EOF Then
'--- Setup Variables ---'
RecordID = Records("RecordID")
Text = Records("Text")
strEditorContent = Replace(Replace(Text,"&","&"),"<","<")
End If
Records.Close
%>
<html>
<head>
<!--#include file="includes/browser_page_encoding_inc.asp" -->
<script language="javascript">
function enableDesignMode() {<%
If RTEenabled = "Gecko" Then Response.Write(" document.desig nMode = 'on'")
%> }
</script>
<STYLE>
td {border:1px dotted #CCCCCC;}
</STYLE>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="setTimeout('enableDesignMode()', 20);">
<% = strEditorContent %></body>
</html>
|
|
pablo_montiel
Newbie
Joined: 09 December 2004
Status: Offline
Points: 16
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2004 at 3:48pm |
My ORIGINAL edit page, was this one (without RTE):
<DIV id=content>
<%
'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")
If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0
If Request.Form("Action") <> "Post" Then
'--- Open set ---'
If (Requested <> 0) AND (Delete <> "True") Then
Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
ElseIf Requested = 0 Then
Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
Else
Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
Database.Close
Set Records = Nothing
Set Database = Nothing
Response.Redirect(SiteURL & PageName)
End If
If NOT Records.EOF Then
'--- Setup Variables ---'
RecordID = Records("RecordID")
Title = Records("Title")
Text = Records("Text")
End If
Records.Close
%>
<Form Name="AddEntry" Method="Post" onSubmit="return setVar()">
<input Name="Action" type="hidden" Value="Post">
<P><span id="Label1">Title : </span><input Name="Title" type="text" value="<%=Replace(Title,"""",""")%>" style="width:80%;" onChange="return setVarChange()"> <a href="?Entry=<%=Requested%>&Delete=True" title="DELETE this entry" onClick="return confirm('Warning! If You Continue Entry #<%=Requested%> Will Be DELETED.')"><img src="<%=SiteURL%>Images/Delete.gif" width="15" height="15" border="0"></a></P>
<P>Content :<br>
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td class="td01" align="left"> </td>
</tr>
<tr>
<td colspan="2">
<textarea Name="Content" DESIGNTIMEDRAGDROP="96" style="height:10em;width:100%;" onChange="return setVarChange()"><%=Replace(Replace(Text,"&","&")," <","<")%></textarea>
</tr>
</table>
</P>
<P></P>
<Input Type="submit" Value="Save">
</form>
<% Else
'Dimension variables
Dim EntryCat &nbs p; 'Category
EntryCat = Request.Form("Category")
'### Filter & Clean ###
EntryCat = Replace(EntryCat,"'","'")
EntryCat = Replace(EntryCat," ","%20")
'### Open The Records Ready To Write ###
Records.CursorType = 2
Records.LockType = 3
If Requested <> 0 Then
Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
Else
Records.Open "SELECT * FROM Data ORDER By RecordID DESC", Database
End If
Records("Title") = Left(Request.Form("Title"),80)
Records("Text") = Request.Form("Content")
Records.Update
Records.Close
Response.Write "<p align=""Center"">Entry Update Successful</p>"
Response.Write "<p align=""Center""><a href=""" & SiteURL & PageName & """>Back</font></a></p>"
End If %>
</Div>
|
|