📄 newsmodify.asp
字号:
<!--#include virtual = "/Include/DBClass.inc.asp"-->
<!--#include virtual = "/Include/SysLoginCheck.inc.asp" -->
<%
Call Header("增加新闻")
Call Content()
Call Footer()
' 开始写入内容
Sub Content()
' 传入参数:新闻ID
Dim sNewsID
sNewsID = GetSafeInt(Trim(Request("id")),0)
If sNewsID < 1 Then
GoError "请通过页面上的链接进行操作,不要试图进行任何非法操作。"
End If
' 从数据库中取初始值
Dim sCataID, sTitle, sContent, sPicture, sSaveFileName, sSavePathFileName,sFrom, sSpecial
sSql = "SELECT * FROM NewsData WHERE D_ID=" & sNewsID
oRs.Open sSql, oConn, 0, 1
If Not oRs.Eof Then
sCataID = oRs("D_CataID")
sTitle = oRs("D_Title")
sContent = oRs("D_Content")
sPicture = oRs("D_Picture")
sSaveFileName = oRs("D_SaveFileName")
sSavePathFileName = oRs("D_SavePathFileName")
sFrom = oRs("D_From")
sSpecial = oRs("D_Special")
Else
GoError "无效的新闻ID,请点页面上的链接进行操作!"
End If
oRs.Close
' 把带"|"的字符串转为数组,用于初始下拉框表单
Dim aSavePathFileName
aSavePathFileName = Split(sSavePathFileName, "|")
' 根据新闻内容中相关上传文件为数据,初始下拉框表单
' 函数InitSelect,根据数组值及初始值返回下拉框输出字串,具体请见startup.asp文件中函数的说明部分
Dim sOptionSavePath
sOptionSavePath = InitSelect("d_picture", aSavePathFileName, aSavePathFileName, sPicture, "", "无")
%>
<!--#include virtual ="/Include/Top.asp" -->
<link href="/style/admin.css" rel="stylesheet" type="text/css">
<br>
<Script Language=JavaScript>
// 当上传图片等文件时,往下拉框中填入图片路径,可根据实际需要更改此函数
function doChange(objText, objDrop){
if (!objDrop) return;
var str = objText.value;
var arr = str.split("|");
var nIndex = objDrop.selectedIndex;
objDrop.length=1;
for (var i=0; i<arr.length; i++){
objDrop.options[objDrop.length] = new Option(arr[i], arr[i]);
}
objDrop.selectedIndex = nIndex;
}
// 表单提交客户端检测
function doSubmit(){
if (document.myform.d_cataid.value==""){
alert("请选择一个新闻类别!");
document.myform.d_cataid.focus();
return false;
}
if (document.myform.d_cataid.value.length < 5){
alert("根目录不允许发布信息!");
document.myform.d_cataid.focus();
return false;
}
if (document.myform.d_title.value==""){
alert("新闻标题不能为空!");
document.myform.d_title.focus();
return false;
}
// getHTML()为eWebEditor自带的接口函数,功能为取编辑区的内容
if (eWebEditor1.getHTML()==""){
alert("新闻内容不能为空!");
return false;
}
return true;
// document.myform.submit();
}
</Script>
<form action="NewsModifySave.asp?id=<%=sNewsID%>" method="post" name="myform" onSubmit="return doSubmit();">
<% '取保存的方件名(带路径),如果不要带路径的填充下拉框,可以在下面的表单项加入onchange事件 %>
<input type=hidden name=d_savefilename value="<%=sSaveFileName%>">
<% '取保存的文件名,使用带路径的填充下拉框 %>
<input type=hidden name=d_savepathfilename onchange="doChange(this,document.myform.d_picture)" value="<%=sSavePathFileName%>">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25"><b><% = Homepage_title%> - <font color="#FF0000">修改新闻</font></b></td>
</tr>
<tr>
<td><table width="100%" border="0" align="center" cellspacing="2" cellpadding="2">
<tr>
<td width="65">新闻类别:</td>
<td>
<select name="d_cataid" size="1" style="background-color:#ECF3FF;">
<option value="">--> 请选择 <--</option>
<%
'开始读取数据库中已经定义的新闻类别
'其实这么写,感觉太没有效率了,应该定义一个子程序
Dim cRs, cSql, j, TempCataStr
Set cRs = Server.CreateObject( "ADODB.Recordset" )
cSql = "SELECT * FROM NewsCata ORDER BY C_RootID"
cRs.Open cSql, oConn, 1, 3
Do While Not cRs.EOF
TempCataStr = "<option value='"&Trim(cRs("C_RootID"))&"'"
If cRs("C_RootID") = sCataID Then TempCataStr = TempCataStr&" selected"
If Len(cRs("C_RootID")) = 1 Then TempCataStr = TempCataStr& " style='color:#FF0000'"
TempCataStr = TempCataStr&"> |"
For j = 1 To Int(Len(Trim(cRs("C_RootID")))/4)
TempCataStr = TempCataStr&" |"
Next
TempCataStr = TempCataStr&"_"&Trim(cRs("C_Title"))&"</option>"
Response.Write TempCataStr
cRs.MoveNext
Loop
cRs.Close
Set cRs = Nothing
%>
</select>
</td>
</tr>
<tr>
<td>新闻标题:</td>
<td><input type="text" name="d_title" value="<%=inHTML(sTitle)%>" size="67"></td>
</tr>
<tr>
<td valign="top">图片附件:</td>
<td><%=sOptionSavePath%> <font color="#FF0000">将自动填充此下拉框。</font></td>
</tr>
<tr>
<td valign="top">新闻内容:</td>
<td> </td>
</tr>
<tr>
<td colspan="2" valign="top">
<textarea name="d_content" style="display:none"><%=Server.HtmlEncode(sContent)%></textarea>
<iframe ID="eWebEditor1" src="../WebEditor/ewebeditor.asp?id=d_content&style=s_newssystem&savefilename=d_savefilename&savepathfilename=d_savepathfilename" frameborder="0" scrolling="no" width="550" HEIGHT="350"></iframe> </td>
</tr>
<tr>
<td>新闻来源:</td>
<td><input name="d_from" type="text" class="button1" value="<%=inHTML(sFrom)%>" size="67"></td>
</tr>
<tr>
<td>推荐新闻:</td>
<td><input type="checkbox" name="d_special" value="1" <%If sSpecial =1 Then Response.Write("checked")%>>是否特别新闻,如果是请打钩。</td>
</tr>
<tr>
<td>阅读权限:</td>
<td>
<select name="d_permission" size="1" style="background-color:#ECF3FF;">
<option value='0' selected>--允许所有人查看--</option>
</select>
</td>
</tr>
<tr>
<td>
<font color="#FF0000">注意事项:</font></td>
<td><font color="#FF0000">以上新闻标题和新闻内容必须填写,其他可以不填。</font></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="btnSubmit" value=" 提 交 " class="button2">
<input type="reset" name="btnReset" value=" 重 填 " class="button2">
</td>
</tr>
</table></td>
</tr>
</table>
</form>
<p> </p>
<%
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -