⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_newsmodify.asp

📁 简单明晰的asp后台代码 新闻 产品
💻 ASP
字号:
<!--#include file = "../inc/dbclass.inc.asp" -->
<!--#include file = "../inc/syslogincheck.inc.asp" -->

<%
' =============================================================
' made by xiasp & 智多网络 http://www.cq18.com/ qq群:12403617
' =============================================================
%>

<%
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 file = "admin_index_top.asp" -->
<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="admin_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="">--&gt; 请选择 &lt;--</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&">&nbsp;|"
		
		for j = 1 to int(len(trim(crs("c_rootid")))/4)
			tempcatastr = tempcatastr&"&nbsp;|"
		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>&nbsp;</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>
          <font color="#ff0000">注意事项:</font></td>
        <td><font color="#ff0000">以上新闻标题和新闻内容必须填写,其他可以不填。</font></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>
          <input type="submit" name="btnsubmit" value=" 提 交 " class="button2">
		  &nbsp;&nbsp;<input type="reset" name="btnreset" value=" 重 填 " class="button2">
        </td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
<p>&nbsp;</p>
<%
end sub
%>

                                                                                              
                                                                                                    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -