I'm using Macromedia Dreamweaver MX with ASP VBScript.
Sorry if I'm blind but I haven't been able to find a simple solution to a (hopefully simple) question - how can I implement FCKEditor to replace a textarea and then insert(/or retreave) its contents into a single Access database field? My goal is to save/retreave a form of which FCKEditor is a part of among various text fields, using the INSERT INTO command when the form is submitted...
Sorry if I'm blind but I haven't been able to find a simple solution to a (hopefully simple) question - how can I implement FCKEditor to replace a textarea and then insert(/or retreave) its contents into a single Access database field? My goal is to save/retreave a form of which FCKEditor is a part of among various text fields, using the INSERT INTO command when the form is submitted...
RE: ASP, textarea and databases
' the field holding the data
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = rs("Information")
' width and height are optional
oFCKeditor.Width = "100%"
oFCKeditor.Height = "300px"
' within your form use
response.write "<textarea rows=""4"" cols=""100"" name=""Information"" >" & rs("Information") & "</textarea>"
RE: ASP, textarea and databases
RE: ASP, textarea and databases
Needing Some Similar Help
Hello, I'm trying to do something similar to what you discribed. Can you help?
Here is my page. Around line 464 is where I'm trying to make the form work.
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%@ Language=VBScript %>
<% Option Explicit
Dim AdminID
Dim AdminRights
Dim AdminLevel
Dim KeyCode
Dim Today
Dim adoConnection
Dim BreakingNews
Dim GeneralNews
Dim SportID
Dim NewsID
Dim StartDate
Dim ExpirationDate
Dim NoExpirationDate
Dim NewsHeader
Dim News
Dim Mode
Dim strSubmit
Dim rsGetSport
Dim rsGetNews
Dim mySQL
Dim CreatedBy
Dim lngCounter
Dim OptionSelected
Dim SportName
Dim i
Dim txtChecked
'Populate variables for use on this page - if used multiple times, as a general rule
AdminID = Session("AdminID")
AdminRights = Session("AdminRights")
AdminLevel = Session("AdminLevel")
KeyCode = Session("KeyCode")
'Make sure they have the rights to be here.
If AdminRights = 0 Then
Response.Redirect("http://www.neiaoa.org/")
End If
'Open connection to database
set adoConnection = server.CreateObject("ADODB.Connection")
adoConnection.ConnectionString = Application("DB_DSN")
adoConnection.Open
'Pull today's date
Today = date
'Check to see what Sport they they chose on Step 1
'SportID = CInt(Request.QueryString("Sport"))
'See if they have submitted to the page
strSubmit = Request.Form("btnSubmit")
Mode = Request.QueryString("Mode")
'They are Canceling the Add News Item
If strSubmit = "Cancel" Then
Response.Redirect ("Admin_Main.asp")
End If
'They are DELETING a News Item
If Mode = "Del" Then
'Get the NewsID
NewsID = CInt(Request.QueryString("ID"))
'DELETE the News Item from the Database
mySQL = _
" DELETE " & _
" FROM News " & _
" WHERE ID = " & NewsID
adoConnection.Execute (mySQL)
Response.Redirect ("News_NewEdit.asp")
End If
'They are EDITING a News Item
If Mode = "Edit" Then
'Get the NewsID
NewsID = CInt(Request.QueryString("ID"))
'Pull the News Item from the Database
Set rsGetNews = server.CreateObject("ADODB.Recordset")
Set rsGetNews.ActiveConnection = adoConnection
mySQL = _
" SELECT * " & _
" FROM News " & _
" WHERE ID = " & NewsID
rsGetNews.Open mySQL,,adOpenStatic,adLockOptimistic,adCmdText
SportID = rsGetNews("SportID")
End If
'They are SAVING from the form
If strSubmit = "Save News" Then
'Pull the Items from the form.
'Response.Write(Request.Form("SportID"))
'Response.End
BreakingNews = Request.Form("BreakingNews")
GeneralNews = Request.Form("GeneralNews")
SportID = CInt(Request.Form("SportID"))
StartDate = Request.Form("StartDate")
ExpirationDate = Request.Form("ExpirationDate")
NoExpirationDate = Request.Form("NoExpirationDate")
NewsHeader = Replace(Request.Form("NewsHeader"), "'", "''")
News = Replace(Request.Form("FCKeditor1"), "'", "''")
Mode = Request.Form("Mode")
NewsID = Request.Form("NewsID")
'This is if there is no BreakingNews
If BreakingNews <> 1 Then
BreakingNews = 0
End If
'This is if there is no GeneralNews
If GeneralNews <> 1 Then
GeneralNews = 0
End If
'This is if there is no NoExpirationDate
If NoExpirationDate <> 1 Then
NoExpirationDate = 0
End If
CreatedBy = Session("FirstName") & " " & Session("LastName")
'Check to see if they are EDITING or INSERTING
If Mode = "Edit" Then
'UPDATE into the Database
mySQL = _
" UPDATE News " & _
" SET BreakingNews=" & BreakingNews & ",GeneralNews=" & GeneralNews & ",SportID=" & SportID & ",StartDate='" & StartDate & "',ExpirationDate='" & ExpirationDate & "',NoExpirationDate=" & NoExpirationDate & ",NewsHeader='" & NewsHeader & "',News='" & News & "',DateCreated='" & Now() & "',CreatedByWho='" & CreatedBy & "'" & _
" WHERE ID = " & NewsID
adoConnection.Execute (mySQL)
'They are INSERTING
Else
'INSERT into the Database
mySQL = "INSERT INTO News (BreakingNews,GeneralNews,SportID,StartDate,ExpirationDate,NoExpirationDate,NewsHeader,News,DateCreated,CreatedByWho)"
mySQL = mySQL & "VALUES (" & BreakingNews & "," & GeneralNews & "," & SportID & ",'" & StartDate & "','" & ExpirationDate & "'," & NoExpirationDate & ",'" & NewsHeader & "','" & News & "','" & Now() & "','" & CreatedBy & "')"
adoConnection.Execute (mySQL)
End If
Response.Redirect ("News_NewEdit.asp")
End If
%>
<!-- #########################This is for the Rich Text Editor ################################ -->
<!--#include file="FCKeditor/fckeditor.asp" -->
<!-- ########################################################################################## -->
<HTML>
<HEAD>
<META http-equiv=Description name=Description content="NEIAOA.org Adminstrative Login" >
<META http-equiv=Keywords name=Keywords content="NEIAOA.org Adminstrative Login" >
<link href="main.css" type="text/css" rel="stylesheet" id="stylesheet" />
<link type="text/css" rel="stylesheet" href="datepickercontrol.css">
<script type="text/javascript" src="datepickercontrol.js"></script>
<script LANGUAGE="JavaScript">
// Begin Confirm Release
function confirmDelete() {
return confirm("Please confirm that you want to DELETE the News Item.");
}
// End Confirm Release
</script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
<TITLE>NEIAOA.org Clinic Administration: Add/Edit News Item</TITLE>
</HEAD>
<body background="images/bkgAdmin.gif">
<table width="750" align="center" border="0" cellpadding="0" cellspacing="0">
<TR>
<TD class=login>
You're logged in as: <%=Session("FirstName")%> <%=Session("LastName")%> |
<A HREF="logout.asp">Log Out</A>
</TD>
</TR>
</table>
<table width="750" align="center" border="1" cellpadding="0" cellspacing="0">
<TR valign="top">
<TD valign="middle">
<img src="images/Admin_Heading.jpg" alt="Admin Area" width="750" height="100" align="top">
</TD>
</TR>
<TR>
<TD class=entry bgcolor="#EEEEEE">
<A HREF="Admin_Main.asp">Admin Home</A> >
Add New News
</TD>
</TR>
<tr>
<td align="center" BGCOLOR="#DDDDDD">
<br />
<table border=1 width="100%">
<form name="form1" id="form1" action="News_NewEdit.asp" method="POST">
<%'If Editing, the Form needs to know these varibles
If Mode = "Edit" Then%>
<input type="hidden" name="Mode" value="Edit">
<input type="hidden" name="NewsID" value="<%= rsGetNews("ID")%>">
<%End If%>
<tr>
<td class=footballcatheading colspan=2>
<%If Mode = "Edit" Then %>
Edit News
<%Else%>
Add New News
<%End If%>
</td>
</tr>
<tr>
<td class="caption">
Breaking News:<br />
(to be put on the home page)
</td>
<td class="entry">
<%
If Mode = "Edit" Then
If rsGetNews("BreakingNews") = 1 Then
txtChecked = "CHECKED"
Else
txtChecked = ""
End If
Else
txtChecked = ""
End If
%>
<input name="BreakingNews" id="BreakingNews" type="checkbox" <%=txtChecked%> value="1" /> Breaking News
</td>
</tr>
<tr>
<td class="caption">
General News:<br />
(to be put on the News page)
</td>
<td class="entry">
<%
If Mode = "Edit" Then
If rsGetNews("GeneralNews") = 1 Then
txtChecked = "CHECKED"
Else
txtChecked = ""
End If
Else
txtChecked = ""
End If
%>
<input name="GeneralNews" id="GeneralNews" type="checkbox" <%=txtChecked%> value="1" /> General News
</td>
</tr>
<tr>
<td class=caption>
News for a Specific Sport:
</td>
<td class="entry">
<select name="SportID">
<%If Mode = "Edit" Then%>
<option value=0>...Select Sport...</option>
<%ElseIf Len(SportID) > 0 Then%>
<option value=0>...Select Sport...</option>
<%Else%>
<option value=0 selected>...Select Sport...</option>
<%End If%>
<%'Pull all of the Sport to populate the pull down list
Set rsGetSport = server.CreateObject("ADODB.Recordset")
Set rsGetSport.ActiveConnection = adoConnection
mySQL = "SELECT ID,SportName FROM Sports ORDER BY SportName"
rsGetSport.Open mySQL,,adOpenStatic,adLockOptimistic,adCmdText
'Some error checking
If rsGetSport.EOF AND rsGetSport.BOF Then
Response.Write "<option value=0>There are No Sports</option>"
'If Sports exists
Else
'Loop over the Sports query we ran above.
Do While Not rsGetSport.EOF
'Response.Write (rsGetSport("ID"))
'Response.Write (rsGetNews("SportID"))
'Response.End
If Mode = "Edit" AND rsGetSport("ID") = SportID Then
OptionSelected = "selected"
SportName = rsGetSport("SportName")
ElseIf rsGetSport("ID") = SportID Then
OptionSelected = "selected"
SportName = rsGetSport("SportName")
Else
OptionSelected = ""
End If
'Response.Write(OptionSelected)
'Set string for output for each option in the select field.
Response.Write "<option " & OptionSelected & " value=" & rsGetSport("ID") & ">" & rsGetSport("SportName") & "</option>"
rsGetSport.MoveNext
Loop
End If
%>
</select>
</td>
</tr>
<tr>
<td class="caption">
Start Date:
</td>
<td class="entry">
<input type="hidden" id="DPC_CALENDAR_OFFSET_X" value="140">
<%If Mode = "Edit" Then%>
<input type="text" name="StartDate" id="StartDate" value="<%=rsGetNews("StartDate")%>" datepicker="true" datepicker_format="MM/DD/YYYY">
<%Else%>
<input type="text" name="StartDate" id="StartDate" value="<%=Today%>" datepicker="true" datepicker_format="MM/DD/YYYY">
<%End If%>
<br><br>
</td>
</tr>
<tr>
<td class="caption">
Expiration Date:
</td>
<td class="entry">
<input type="hidden" id="DPC_CALENDAR_OFFSET_X" value="140">
<%If Mode = "Edit" Then%>
<input type="text" name="ExpirationDate" id="ExpirationDate" value="<%=rsGetNews("ExpirationDate")%>" datepicker="true" datepicker_format="MM/DD/YYYY">
<%Else%>
<input type="text" name="ExpirationDate" id="ExpirationDate" value="<%=Today+7%>" datepicker="true" datepicker_format="MM/DD/YYYY">
<%End If%>
<br />
<%
If Mode = "Edit" Then
If rsGetNews("NoExpirationDate") = 1 Then
txtChecked = "CHECKED"
Else
txtChecked = ""
End If
Else
txtChecked = ""
End If
%>
<input name="NoExpirationDate" id="NoExpirationDate" type="checkbox" <%=txtChecked%> value="1" /> No Expiration Date
</td>
</tr>
<tr>
<td class="caption">
News Header:<br />
(this is optional)
</td>
<td class="entry">
<%
If Mode = "Edit" Then
If Len(rsGetNews("NewsHeader")) > 0 Then
NewsHeader = rsGetNews("NewsHeader")
Else
NewsHeader = ""
End If
Else
NewsHeader = ""
End If
%>
<input name="NewsHeader" id="NewsHeader" type="text" value="<%=NewsHeader%>" size="75" />
</td>
</tr>
<tr>
<td class="entry" colspan=2>
Use the box below to add your text.<br />
</td>
</tr>
<tr>
<!--
<td class="entry" colspan=2>
<%
Dim oFCKeditor
If Mode = "Edit" Then
'News = rsGetNews("Notes")
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "FCKeditor/FCKeditor/"
oFCKeditor.Value = rsGetNews("News").Value
oFCKeditor.Create "FCKeditor1"
'oFCKeditor.Value = rsNews.Fields.Item("NewsBody").Value)
Else
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "FCKeditor/FCKeditor/"
oFCKeditor.Create "FCKeditor1"
End If
%>
</td>
-->
<td class="entry" colspan=2>
<textarea id="editor1" name="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</td>
</tr>
<tr>
<td colspan=2 align=right>
<input type=submit name=btnSubmit value="Cancel">
<input type=submit name=btnSubmit value="Save News">
</td>
</tr>
</form>
</table>
<br /><br />
</td>
</tr>
<!-- ################################## LIST OF CURRENT NEWS ITEMS ################################-->
<%'Check to see what season it is based on today's date
%>
<TR>
<TD align="center" bgcolor="#EEEEEE">
<table border=1 cellpadding=3 cellspacing=2>
<tr>
<td class=footballcatheading colspan=8>
Current News
</td>
</tr>
<!-- List of News -->
<%
'Pull all of the News
Set rsGetNews = server.CreateObject("ADODB.Recordset")
Set rsGetNews.ActiveConnection = adoConnection
mySQL = _
" SELECT *,SportID AS SportID " & _
" FROM News " & _
" WHERE (NoExpirationDate = 1) OR ((NoExpirationDate = 0) AND ExpirationDate >='" & Today & "') " & _
" ORDER BY StartDate "
'Response.Write(mySQL)
'Response.End
rsGetNews.Open mySQL,,adOpenStatic,adLockOptimistic,adCmdText
If Not (rsGetNews.EOF AND rsGetNews.BOF) Then
rsGetNews.MoveFirst
lngCounter = 1
Do While Not rsGetNews.EOF
%>
<tr class=footballsubheading>
<td> </td>
<td>News Start Date</td>
<td>News End Date</td>
<td>Breaking News</td>
<td>General News</td>
<td>Sport</td>
<td>Created By</td>
<td> </td>
</tr>
<%
If (lngCounter MOD 2) = 1 Then
Response.Write("<tr class=""footballlist-odd"">")
Else
Response.Write("<tr class=""footballlist-even"">")
End If
%>
<td class=listentry nowrap>
<%=lngCounter%>.
</td>
<td class=listentry nowrap>
<%= rsGetNews("StartDate")%>
</td>
<td class=listentry nowrap>
<%
'Check to see if there is an End Date
If rsGetNews("NoExpirationDate") = 1 Then
Response.Write "No End Date"
Else
Response.Write (rsGetNews("ExpirationDate"))
End If
%>
</td>
<td class=listentry nowrap>
<%
If rsGetNews("BreakingNews") = 1 Then
Response.Write "Yes"
Else
Response.Write "No"
End If
%>
</td>
<td class=listentry nowrap>
<%
If rsGetNews("GeneralNews") = 1 Then
Response.Write "Yes"
Else
Response.Write "No"
End If
%>
</td>
<td class=listentry nowrap>
<%'Check to see if there is a Sport
If rsGetNews("SportID") > 0 Then
'Pull the Sport
Set rsGetSport = server.CreateObject("ADODB.Recordset")
Set rsGetSport.ActiveConnection = adoConnection
mySQL = _
" SELECT * " & _
" FROM Sports " & _
" WHERE ID=" & rsGetNews("SportID")
'Response.Write(mySQL)
'Response.End
rsGetSport.Open mySQL,,adOpenStatic,adLockOptimistic,adCmdText
Response.Write (rsGetSport("SportName"))
'Close Record Set
If rsGetSport.state = adStateOpen Then
rsGetSport.Close
End If
set rsGetSport = nothing
Else
Response.Write "No Sport"
End If
%>
</td>
<td class=listentry nowrap>
<%= rsGetNews("CreatedByWho")%><br />
<%= rsGetNews("DateCreated")%>
</td>
<td class=listentry nowrap>
<a href="News_NewEdit.asp?ID=<%=rsGetNews("ID")%>&Mode=Edit">Edit</a> |
<a href="News_NewEdit.asp?ID=<%=rsGetNews("ID")%>&Mode=Del" onClick="return confirmDelete();">Delete...</a>
</td>
</tr>
<%
If (lngCounter MOD 2) = 1 Then
Response.Write("<tr class=""footballlist-odd"">")
Else
Response.Write("<tr class=""footballlist-even"">")
End If
%>
<td colspan=8><div class="NewsHeader">
<%= rsGetNews("NewsHeader")%></div><br /><br />
<%= rsGetNews("News")%>
</td>
</tr>
<%
rsGetNews.MoveNext
lngCounter = lngCounter + 1
Loop
Else
%>
<tr>
<td colspan="9" class="errormessage">
There were no news items were found in the database.
</td>
</tr>
<%
End If
If rsGetNews.state = adStateOpen Then
rsGetNews.Close
End If
set rsGetNews = nothing
%>
</table>
</TD>
</TR>
</table>
</BODY>
</HTML>