I'm trying to implement the CuteEditor for many of my <TEXTAREA> form elements and hook it up to my database. I don't want to use the code in todatabse.asp file example because I've already got code for existing pages that writes to the database. I just want to display the CuteEditor for my TEXTAREA fields and have it work with the database. The code I've implemented reads from the database, buy when I submit, it deletes the contents of the field in question. Here's my code (with the CuteEditor parts in bold:
<!-- #include file=utils.asp -->
<!-- #include file = "CuteEditor_Files/include_CuteEditor.asp" -->
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1 ">
<script language="javascript">
function openImageLibrary(){
myWin=open("default_image.asp" ,"Images","width=450,height=460,status=no,toolbar=no,menubar=no,scrollbars=yes"); }
</script>
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "htmlarea/"; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// -->
</script>
<link rel="stylesheet" type="text/css" href="fontcss.css" />
<title>FrontPages</title>
</head>
<body><center>
<!-- #include file ="header.asp" -->
<form method= post action=FrontPagesDetailadmin.asp onSubmit="return validateForm();" name=FrontPages> <table width=80%>
<!-- #include file ="sec.asp" -->
<tr><td><b><a href="BLOCKED SCRIPTopenImageLibrary();">image library</a></b><br><br></td></tr>
<tr><td colspan=2><a href=FrontPagesListadmin.asp><< back to List</a><br><br></td></tr>
<tr><td colspan=2> <b>Edit Front Page Content</b><br></td></tr>
<% if request.querystring("id")="" then response.redirect("FrontPagesListadmin.asp")
strsql="select * from [FrontPages] where [FrontKey]=" & request.querystring("id")
rs.open strsql,mydsn
if rs.eof and rs.bof then%>
<tr><td colspan=2>No records!</td></tr>
<%'clean up!
rs.close
set rs=nothing
response.end
end if%>
<tr><td valign="top"></td><td><input type="hidden" name="txtFrontKey" value="<%=rs("FrontKey")%>" size=30></td></tr>
<input type="hidden" name="txtFrontPage" value="<%=rs("FrontPage")%>">
<tr><td valign="top">Front Page Section <font color="#FF0000"><b>*</b></font></td><td>
<select size="1" name="txtFrontPageSection">
<option selected value="<%=rs("FrontPageSection")%>"><%=rs("FrontPageSection")%>
</option>
<option value="Top Left Box">Top Left Box</option>
<option value="Top Right Box 1">Top Right Box 1</option>
<option value="Top Right Box 2">Top Right Box 2</option>
<option value="Bottom Left Box">Bottom Left Box</option>
<option value="Bottom Right Box 1">Bottom Right Box 1</option>
<option>Bottom Right Box 2</option>
</select></td></tr>
<tr><td valign="top">Heading <font color="#FF0000"><b>*</b></font></td><td>
<!-- <textarea name="txtFrontHeading" cols="55" rows="2"><%=rs("FrontHeading")%></textarea> -->
<%
dim content
content = rs("FrontHeading")
Dim editor
Set editor = New CuteEditor 'Create a new editor class object
'Set the ID of this editor class
editor.ID = "Editor1"
'Set the initial HTML value of editor control
editor.Text = content
editor.FilesPath = "CuteEditor_Files"
'The toolbar items needed to be disabled going to this string. Example DisableItemList="Bold, New, Delete"
editor.DisableItemList = "Save"
editor.ThemeType="Office2003"
editor.EditorWysiwygModeCss = "asp.css"
editor.Draw()
Request.Form("txtFrontHeading")
%>
</td></tr>
<!--
<script language="javascript1.2">
editor_generate('txtFrontHeading');
</script>
-->
<tr><td valign="top">Copy <font color="#FF0000"><b>*</b></font></td><td>
<textarea name="txtFrontCopy" cols="55" rows="10"><%=rs("FrontCopy")%></textarea></td></tr>
<script language="javascript1.2">
editor_generate('txtFrontCopy');
</script>
<tr><td valign="top">Image Code</td><td>
<textarea name="txtFrontImg" cols="55" rows="5"><%=rs("FrontImg")%></textarea></td></tr>
<script language="javascript1.2">
editor_generate('txtFrontImg');
</script>
<tr><td valign="top">Read More URL</td><td>
<textarea name="txtFrontReadMoreURL" cols="55" rows="2"><%=rs("FrontReadMoreURL")%></textarea></td></tr>
<%if rs("FrontDisplay")=-1 then chkFrontDisplay="checked" 'check for true value for checkbox %>
<tr><td valign="top">Display On Front Page?</td><td><input type="checkbox" name="txtFrontDisplay" <%=chkFrontDisplay%>>
(Check to make live on the site)</td></tr>
<tr><td><input type="hidden" value="<%=request.querystring("id")%>" name="id"><input type="hidden" name="doValidate"><input type="button" value="Delete" name="delete" onClick="confirmDelete();"></td><td><input type="submit" value="Update" name="submit"></td></tr>
<tr><td colspan=2><br><br><font size=1 color=red>*</font><font size=1> required field.</font></td></tr>
</table></form>
<!-- #include file ="footer.asp" -->
</center></body></html>
<%'these are the functions that pass the sql to the xrecord function that can be found in the utils.asp file
sub doRecord()
if request.form("txtFrontDisplay")="" then
sqlFrontDisplay=0
else
sqlFrontDisplay=request.form("txtFrontDisplay")
end if
strSql="Update [FrontPages] Set FrontPage='" & replace(request.form("txtFrontPage"),"'","''") & "',FrontPageSection='" & replace(request.form("txtFrontPageSection"),"'","''") & "',FrontHeading='" & replace(request.form("txtFrontHeading"),"'","''") & "',FrontCopy='" & replace(request.form("txtFrontCopy"),"'","''") & "',FrontImg='" & replace(request.form("txtFrontImg"),"'","''") & "',FrontReadMoreURL='" & replace(request.form("txtFrontReadMoreURL"),"'","''") & "',[FrontDisplay]=" & sqlFrontDisplay & " where [FrontKey]=" & request.form("id")
xRecord strSql,"FrontPagesListadmin.asp?s=2"
end sub
sub delRecord()
strSql="delete * from [FrontPages] where FrontKey=" & request.querystring("d")
xRecord strSql,"FrontPagesListadmin.asp?s=3"
end sub %>
<script type="text/javascript">
function validateForm() {
if (document.forms[0].txtFrontDisplay.value == "")
{self.alert("You must make an entry in FrontDisplay!");
document.forms[0].txtFrontDisplay.focus();
return false;}
}
function confirmDelete() {
if(confirm("Are you sure you want to delete this?")){
self.location.href="FrontPagesDetailAdmin.asp?d=<%=request.querystring("id")%>"
}
else { return false }
}
</script>