| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1346 人关注过本帖
标题:做个类似编程论坛里的发表帖子的程序怎么写?
只看楼主 加入收藏
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
在客户端用javascript取得编辑器的内容提交到服务器端,服务器端就不需要用循环了。
2007-09-18 13:16
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 

dim upload,upfile,filename
set upload=new upload_5xsoft 'upload就是一个对象
set file=upload.file("file")
if file.fileSize>0 then
filename=getname() & getext(file.filename)
file.saveAs Server.mappath("upload/" & filename)
end if

Title=htmlencode(Trim(upload.form("Title")))
'Content =htmlencode(Trim(upload.Form("content")))'这行如果运行是正确的,但如果把内容中加了格式编辑就会出错,提示内容太多.
Content = ""
For i = 1 To upload.Form("content").Count'这行如果用request.Form("content").Count就不会出错.
Content = Content & upload.Form("content")(i)'出错
Next
set rs=server.createobject("adodb.recordset")
sql="select * from anli where ID=null"
rs.open sql,Conn,1,3
rs.addnew

rs("Title")=Title
rs("filename")=filename

rs("Content")=Content

rs.update
rs.close
Call CloseConn()
function getname()
dim s
s=now()
s=replace(s,"-","")
s=replace(s," ","")
s=replace(s,":","")
getname=s
end function
function getext(s)
dim str,num
str=split(s,".")
num=ubound(str)
if num=0 then
getext="no"
else
getext="." & str(num)
end if

end function
这是我现在拼凑的源码,因为原来的源码我发现出错以后就重新给改了.

2007-09-18 13:23
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 
但该怎么实现用javascript把客户端的编辑器的内容提交到服务器端呢?
2007-09-18 13:26
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
楼主客户端的编辑器用的是什么textare?
客户端的代码贴出来看看。
2007-09-18 13:29
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 

<form action="anliSaveAdd.asp" method="post" enctype="multipart/form-data" name="form1" onSubmit="return Juge(this)">
<table width="653" border="0" cellpadding="0" cellspacing="1" bgcolor="#6699CC" class="tableborder">
<tr align="center" valign="middle">
<td height="25" colspan="2" class="title"><strong>上传案例</strong></td>
</tr>
<tr valign="middle" class="tdbg">
<td height="30" align="center">上传图片:</td>
<td height="30"><iframe frameborder="0" width="500" height="30" scrolling="no" src="upload_form.asp" ></iframe></td>
</tr>
<tr valign="middle" class="tdbg">
<td height="30" align="center">图片标题:</td>
<td height="30"><input name="Title" type="text" class="input2" size="89" maxlength="250"></td>
</tr>
<tr valign="middle" class="tdbg">
<td width="100" align="center">详细说明:</td>
<td width="550"><textarea name="content" style="display:none"></textarea>
<iframe ID="eWebEditor1" src="../eWebEditor/ewebeditor.asp?id=content&style=Article&savepathfilename=savepathfilename" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe></td>
</tr>
</table>
<span class="tdbg">
<br>
<input name="Submit" type="submit" value=" 确 定 ">
<input name="Reset" type="reset" id="Reset" value=" 取 消 ">
</span>
</form>
</center>
这是初始页
下面的是="../eWebEditor/ewebeditor.asp这个页面.特别多,我都没有看其中的代码
<!--#include file = "Include/Startup.asp"-->
<%
' 初始输入参数
Dim sContentID, sStyleID, sFullScreen
Dim sStyleName, sStyleDir, sStyleCSS, sStyleUploadDir, nStateFlag, sDetectFromWord, sInitMode, sBaseUrl, sBaseHref, sAutoRemote, sShowBorder
Dim sVersion, sReleaseDate, sLicense

Dim aButtonCode(), aButtonHTML()
Dim sToolBar, sToolBarNormal, sToolBarFullScreen

' 初始化
Call Init()

%>


<html>
<head>
<title>eWebEditor - eWebSoft在线编辑器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/<%=sStyleCSS%>/Editor.css" type="text/css" rel="stylesheet">

<Script Language=Javascript>
var sPath = document.location.pathname;
sPath = sPath.substr(0, sPath.length-14);

var sLinkFieldName = "<%=sContentID%>" ;
var sLinkOriginalFileName = "<%=Request.QueryString("originalfilename")%>" ;
var sLinkSaveFileName = "<%=Request.QueryString("savefilename")%>" ;
var sLinkSavePathFileName = "<%=Request.QueryString("savepathfilename")%>" ;

// 全局设置对象
var config = new Object() ;
config.Version = "<%=sVersion%>" ;
config.ReleaseDate = "<%=sReleaseDate%>" ;
config.License = "<%=sLicense%>" ;
config.StyleName = "<%=sStyleName%>";
config.StyleMenuHeader = "<head><link href=\""+sPath+"css/<%=sStyleCSS%>/MenuArea.css\" type=\"text/css\" rel=\"stylesheet\"></head><body scroll=\"no\" onConTextMenu=\"event.returnValue=false;\">";
config.StyleDir = "<%=sStyleDir%>";
config.StyleUploadDir = "<%=sStyleUploadDir%>";
config.InitMode = "<%=sInitMode%>";
config.AutoDetectPasteFromWord = <%=sDetectFromWord%>;
config.BaseUrl = "<%=sBaseUrl%>";
config.BaseHref = "<%=sBaseHref%>";
config.AutoRemote = "<%=sAutoRemote%>";
config.ShowBorder = "<%=sShowBorder%>";

var sBaseHref = "";
if(config.BaseHref!=""){
sBaseHref = "<base href=\"" + document.location.protocol + "//" + document.location.host + config.BaseHref + "\">";
}
config.StyleEditorHeader = "<head><link href=\"" + sPath + "css/<%=sStyleCSS%>/EditorArea.css\" type=\"text/css\" rel=\"stylesheet\">" + sBaseHref + "</head><body MONOSPACE>" ;
</Script>
<Script Language=Javascript src="include/editor.js"></Script>
<Script Language=Javascript src="include/table.js"></Script>
<Script Language=Javascript src="include/menu.js"></Script>

<script language="javascript" event="onerror(msg, url, line)" for="window">
return true ; // 隐藏错误
</script>

</head>

<body SCROLLING=no >

<table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%'>
<tr><td>

<%=sToolBar%>

</td></tr>
<tr><td height='100%'>

<table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%'>
<tr><td height='100%'>
<input type="hidden" ID="ContentEdit" value="">
<input type="hidden" ID="ModeEdit" value="">
<input type="hidden" ID="ContentLoad" value="">
<input type="hidden" ID="ContentFlag" value="0">
<iframe class="Composition" ID="eWebEditor" MARGINHEIGHT="1" MARGINWIDTH="1" width="100%" height="100%" scrolling="yes">
</iframe>
</td></tr>
</table>

</td></tr>

<% If nStateFlag = 1 Then %>
<tr><td height=25>

<TABLE border="0" cellPadding="0" cellSpacing="0" width="100%" class=StatusBar height=25>
<TR valign=middle>
<td>
<table border=0 cellpadding=0 cellspacing=0 height=20>
<tr>
<td width=10></td>
<td class=StatusBarBtnOff id=eWebEditor_CODE onClick="setMode('CODE')"><img border=0 src="buttonimage/<%=sStyleDir%>/modecode.gif" width=50 height=15 align=absmiddle></td>
<td width=5></td>
<td class=StatusBarBtnOff id=eWebEditor_EDIT onClick="setMode('EDIT')"><img border=0 src="buttonimage/<%=sStyleDir%>/modeedit.gif" width=50 height=15 align=absmiddle></td>
<td width=5></td>
<td class=StatusBarBtnOff id=eWebEditor_TEXT onClick="setMode('TEXT')"><img border=0 src="buttonimage/<%=sStyleDir%>/modetext.gif" width=50 height=15 align=absmiddle></td>
<td width=5></td>
<td class=StatusBarBtnOff id=eWebEditor_VIEW onClick="setMode('VIEW')"><img border=0 src="buttonimage/<%=sStyleDir%>/modepreview.gif" width=50 height=15 align=absmiddle></td>
</tr>
</table>
</td>
<td align=center id=eWebEditor_License style="font-size:9pt"></td>
<td align=right>
<table border=0 cellpadding=0 cellspacing=0 height=20>
<tr>
<td style="cursor:pointer;" onClick="sizeChange(300)"><img border=0 SRC="buttonimage/<%=sStyleDir%>/sizeplus.gif" width=20 height=20 alt="增高编辑区"></td>
<td width=5></td>
<td style="cursor:pointer;" onClick="sizeChange(-300)"><img border=0 SRC="buttonimage/<%=sStyleDir%>/sizeminus.gif" width=20 height=20 alt="减小编辑区"></td>
<td width=40></td>
</tr>
</table>
</td>
</TR>
</Table>

</td></tr>
<% End If %>

</table>

<div id="eWebEditor_Temp_HTML" style="VISIBILITY: hidden; OVERFLOW: hidden; POSITION: absolute; WIDTH: 1px; HEIGHT: 1px"></div>

<form id="eWebEditor_UploadForm" action="upload.asp?action=remote&type=remote&style=<%=sStyleName%>" method="post" target="eWebEditor_UploadTarget">
<input type="hidden" name="eWebEditor_UploadText">
</form>
<iframe name="eWebEditor_UploadTarget" width=0 height=0></iframe>
<div id=divProcessing style="width:200px;height:30px;position:absolute;display:none">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#000000" width="100%" height="100%"><tr><td bgcolor=#3A6EA5><marquee align="middle" behavior="alternate" scrollamount="5" style="font-size:9pt"><font color=#FFFFFF>...远程文件收集中...请等待...</font></marquee></td></tr></table>
</div>

</body>
</html>


<%


' 显示调用错误提示
Sub ShowErr(str)
Call DBConnEnd()
Response.Write "调用错误:" & str
Response.End
End Sub

' 初始化
Sub Init()
' 取全屏标志
sFullScreen = Trim(Request.QueryString("fullscreen"))
' 取对应的内容ID
sContentID = Trim(Request.QueryString("id"))
If sContentID = "" Then ShowErr "请传入调用参数ID,即隐藏的内容表单项ID!"

' 取样式初始值
sStyleName = Get_SafeStr(Trim(Request.QueryString("style")))
If sStyleName = "" Then sStyleName = "standard"

Dim s_SelfUrl, s_ApplicationName, n_Application, i
s_SelfUrl = UCase(Request.ServerVariables("SERVER_NAME") & ":" & Request.ServerVariables("SERVER_PORT") & Request.ServerVariables("SCRIPT_NAME") & "?style=" & sStyleName)
n_Application = 0

Dim aApplicationName, aApplicationUrl, aApplicationValue
aApplicationName = Application("eWebEditor_ApplicationName")
aApplicationUrl = Application("eWebEditor_ApplicationUrl")

If IsArray(aApplicationName) = True Then
n_Application = UBound(aApplicationName)

' 是否在内存中
For i = 1 To n_Application
If aApplicationUrl(i) = s_SelfUrl Then
s_ApplicationName = aApplicationName(i)
aApplicationValue = Application(s_ApplicationName)
sStyleID = aApplicationValue(0)
sStyleName = aApplicationValue(1)
sStyleDir = aApplicationValue(2)
sStyleCSS = aApplicationValue(3)
sStyleUploadDir = aApplicationValue(4)
nStateFlag = aApplicationValue(5)
sDetectFromWord = aApplicationValue(6)
sInitMode = aApplicationValue(7)
sBaseUrl = aApplicationValue(8)
sVersion = aApplicationValue(9)
sReleaseDate = aApplicationValue(10)
sLicense = aApplicationValue(11)
sToolBarNormal = aApplicationValue(12)
sToolBarFullScreen = aApplicationValue(13)
sBaseHref = aApplicationValue(14)
sAutoRemote = aApplicationValue(15)
sShowBorder = aApplicationValue(16)
If sFullScreen = "1" Then
sToolBar = sToolBarFullScreen
Else
sToolBar = sToolBarNormal
End If
Exit Sub
End If
Next
End If


' 初始化数据库连接
Call DBConnBegin()

sSql = "select * from ewebeditor_style where s_name='" & sStyleName & "'"
oRs.Open sSql, oConn, 0, 1
If Not oRs.Eof Then
sStyleID = oRs("S_ID")
sStyleName = oRs("S_Name")
sStyleDir = oRs("S_Dir")
sStyleCSS = oRs("S_CSS")
sStyleUploadDir = oRs("S_UploadDir")
nStateFlag = oRs("S_StateFlag")
sAutoRemote = CStr(oRs("S_AutoRemote"))
sShowBorder = CStr(oRs("S_ShowBorder"))
sDetectFromWord = oRs("S_DetectFromWord")
sInitMode = oRs("S_InitMode")
sBaseUrl = oRs("S_BaseUrl")
sBaseHref = oRs("S_BaseHref")
Else
ShowErr "无效的样式Style参数传入,如果要使用默认值,请留空!"
End If
oRs.Close

' 取版本号及发布日期
sSql = "select sys_version,sys_releasedate,sys_license from ewebeditor_system"
oRs.Open sSql, oConn, 0, 1
sVersion = oRs(0)
sReleaseDate = oRs(1)
sLicense = oRs(2)
oRs.Close

' 取所有按钮
Call InitButtonArray()
' 取样式下的工具栏及按钮
Call InitToolBar()
' 断开数据库连接
Call DBConnEnd()

If sFullScreen = "1" Then
sToolBar = sToolBarFullScreen
Else
sToolBar = sToolBarNormal
End If

n_Application = n_Application + 1
If n_Application = 1 Then
Redim aApplicationName(1)
Redim aApplicationUrl(1)
Else
Redim Preserve aApplicationName(n_Application)
Redim Preserve aApplicationUrl(n_Application)
End If
Redim aApplicationValue(16)
s_ApplicationName = "eWebEditor" & n_Application
aApplicationName(n_Application) = s_ApplicationName
aApplicationUrl(n_Application) = s_SelfUrl
aApplicationValue(0) = sStyleID
aApplicationValue(1) = sStyleName
aApplicationValue(2) = sStyleDir
aApplicationValue(3) = sStyleCSS
aApplicationValue(4) = sStyleUploadDir
aApplicationValue(5) = nStateFlag
aApplicationValue(6) = sDetectFromWord
aApplicationValue(7) = sInitMode
aApplicationValue(8) = sBaseUrl
aApplicationValue(9) = sVersion
aApplicationValue(10) = sReleaseDate
aApplicationValue(11) = sLicense
aApplicationValue(12) = sToolBarNormal
aApplicationValue(13) = sToolBarFullScreen
aApplicationValue(14) = sBaseHref
aApplicationValue(15) = sAutoRemote
aApplicationValue(16) = sShowBorder

Application.Lock
Application("eWebEditor_ApplicationName") = aApplicationName
Application("eWebEditor_ApplicationUrl") = aApplicationUrl
Application(s_ApplicationName) = aApplicationValue
Application.Unlock

End Sub


' 初始化按钮数组
Sub InitButtonArray()
Dim i
sSql = "select * from ewebeditor_button order by b_order asc"
oRs.Open sSql, oConn, 0, 1
i = 0
Do While Not oRs.Eof
i = i + 1
Redim Preserve aButtonCode(i)
Redim Preserve aButtonHTML(i)
aButtonCode(i) = oRs("B_Code")
Select Case oRs("B_Type")
Case 0
aButtonHTML(i) = "<DIV CLASS=""" & oRs("B_Class") & """ TITLE=""" & oRs("B_Title") & """ onclick=""" & oRs("B_Event") & """><IMG CLASS=""Ico"" SRC=""buttonimage/" & sStyleDir & "/" & oRs("B_Image") & """></DIV>"
Case 1
aButtonHTML(i) = "<SELECT CLASS=""" & oRs("B_Class") & """ onchange=""" & oRs("B_Event") & """>" & oRs("B_HTML") & "</SELECT>"
Case 2
aButtonHTML(i) = "<DIV CLASS=""" & oRs("B_Class") & """>" & oRs("B_HTML") & "</DIV>"
End Select
oRs.MoveNext
Loop
oRs.Close
End Sub

' 由按钮代码得到按钮的最终输出
Function Code2HTML(s_Code)
Dim i
Code2HTML = ""
For i = 1 To UBound(aButtonCode)
If UCase(aButtonCode(i)) = UCase(s_Code) Then
Code2HTML = aButtonHTML(i)
Exit Function
End If
Next
End Function

' 初始化工具栏
Sub InitToolBar()
Dim aButton, n
sSql = "select t_button from ewebeditor_toolbar where s_id=" & sStyleID & " order by t_order asc"
oRs.Open sSql, oConn, 0, 1
If Not oRs.Eof Then
sToolBarNormal = "<table border=0 cellpadding=0 cellspacing=0 width='100%' class='Toolbar' id='eWebEditor_Toolbar'>"
sToolBarFullScreen = "<table border=0 cellpadding=0 cellspacing=0 width='100%' class='Toolbar' id='eWebEditor_Toolbar'>"
Do While Not oRs.Eof
sToolBarNormal = sToolBarNormal & "<tr><td><div class=yToolbar>"
sToolBarFullScreen = sToolBarFullScreen & "<tr><td><div class=yToolbar>"
aButton = Split(oRs("T_Button"), "|")
For n = 0 To UBound(aButton)
sToolBarNormal = sToolBarNormal & Code2HTML(aButton(n))
If UCase(aButton(n)) = "MAXIMIZE" Then
aButton(n) = "Minimize"
End If
sToolBarFullScreen = sToolBarFullScreen & Code2HTML(aButton(n))
Next
sToolBarNormal = sToolBarNormal & "</div></td></tr>"
sToolBarFullScreen = sToolBarFullScreen & "</div></td></tr>"
oRs.MoveNext
Loop
sToolBarNormal = sToolBarNormal & "</table>"
sToolBarFullScreen = sToolBarFullScreen & "</table>"
Else
ShowErr "对应样式没有设置工具栏!"
End If
oRs.Close
End Sub
%>

2007-09-18 13:34
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 
<form action="anliSaveAdd.asp" method="post" enctype="multipart/form-data" name="form1" onSubmit="return Juge(this)">
<table width="653" border="0" cellpadding="0" cellspacing="1" bgcolor="#6699CC" class="tableborder">
<tr align="center" valign="middle">
<td height="25" colspan="2" class="title"><strong>上传案例</strong></td>
</tr>
<tr valign="middle" class="tdbg">
<td height="30" align="center">上传图片:</td>
<td height="30"><iframe frameborder="0" width="500" height="30" scrolling="no" src="upload_form.asp" ></iframe></td>
</tr>
<tr valign="middle" class="tdbg">
<td height="30" align="center">图片标题:</td>
<td height="30"><input name="Title" type="text" class="input2" size="89" maxlength="250"></td>
</tr>
<tr valign="middle" class="tdbg">
<td width="100" align="center">详细说明:</td>
<td width="550"><textarea name="content" style="display:none"></textarea>
<iframe ID="eWebEditor1" src="../eWebEditor/ewebeditor.asp?id=content&style=Article&savepathfilename=savepathfilename" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe></td>
</tr>
</table>
<span class="tdbg">
<br>
<input name="Submit" type="submit" value=" 确 定 ">
<input name="Reset" type="reset" id="Reset" value=" 取 消 ">
</span>
</form>
</center>
这就是用到textarea的初始页
2007-09-18 13:44
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
textarea的初始页加一段javascript代码
<script language="javascript">
function form1_Submit()
{
document.form1.content.value=eWebEditor1.getHTML();
}
</script>
onSubmit="return Juge(this)">
在Juge这个函数的最开始部分调用form1_Submit()函数
'Content =htmlencode(Trim(upload.Form("content")))'这行如果运行是正确的,但如果把内容中加了格式编辑就会出错,提示内容太多
还可以使用这句话,出错原因可能是楼主数据库Content的最大值设置得太小或者
进行截取字符
Content =htmlencode(Trim(upload.Form("content")))'这句话后面截取字符
Content=Mid(Content,1,[截取多少字符的数量])
2007-09-18 14:00
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 
对啊,犯了一个错误,把数据库里content的设计成文本(30)了.
<script language="javascript">
<!--
function Juge(theForm)
{
document.form1.content.value=eWebEditor1.getHTML(); '这句是我加上的.这句是应该加在这里吗?
if (theForm.Title.value=="")
{
alert("请填写文章标题!");
theForm.Title.focus();
return (false);
}
if (eWebEditor1.getHTML()==""){
alert("中文文章内容不能为空!");
eWebEditor1.focus();
return (false);
}
//if (eWebEditor2.getHTML()==""){
//alert("英文文章内容不能为空!");
//eWebEditor2.focus();
//return (false);
//}
if (theForm.Content.value.length>64000)
{
alert("文章内容太长,超出了ACCESS数据库的限制(64K)!建议将文章分成几部分录入。");
eWebEditor1.focus();
return (false);
}
return (true);
}
//-->
</script>
是这样修改judge()吗?
斑竹,你真的很厉害
2007-09-18 15:12
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
以下是引用lijuan2083在2007-9-18 15:12:13的发言:
对啊,犯了一个错误,把数据库里content的设计成文本(30)了.
<script language="javascript">
<!--
function Juge(theForm)
{
document.form1.content.value=eWebEditor1.getHTML(); '这句是我加上的.这句是应该加在这里吗?
if (theForm.Title.value=="")
{
alert("请填写文章标题!");
theForm.Title.focus();
return (false);
}
if (eWebEditor1.getHTML()==""){
alert("中文文章内容不能为空!");
eWebEditor1.focus();
return (false);
}
//if (eWebEditor2.getHTML()==""){
//alert("英文文章内容不能为空!");
//eWebEditor2.focus();
//return (false);
//}
if (theForm.Content.value.length>64000)
{
alert("文章内容太长,超出了ACCESS数据库的限制(64K)!建议将文章分成几部分录入。");
eWebEditor1.focus();
return (false);
}
return (true);
}
//-->
</script>
是这样修改judge()吗?
斑竹,你真的很厉害

对没错就是这样。

2007-09-18 15:14
lijuan2083
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-7-4
收藏
得分:0 
谢谢你了,我再看一下,还会不会有问题.
2007-09-18 15:23
快速回复:做个类似编程论坛里的发表帖子的程序怎么写?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046670 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved