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

📄 admin_newsadd.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 getnewscata()
	dim crs, csql, i, 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 len(crs("c_rootid")) = 1 then tempcatastr = tempcatastr& " style='color:#ff0000'" 
		tempcatastr = tempcatastr&">&nbsp;|"
		
		for i=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
end sub

' 开始写入内容
sub content()
%>
<!--#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_newsaddsave.asp" method="post" name="myform" onsubmit="return dosubmit();">
<% '取保存的方件名,如果不要带路径的填充下拉框,可以在下面的表单项加入onchange事件 %>
<input type=hidden name=d_savefilename>
<% '取保存的文件名(带路径),使用带路径的填充下拉框 %>
<input type=hidden name=d_savepathfilename onchange="dochange(this,document.myform.d_picture)">

<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>
            <%call getnewscata()%>
          </select>
        </td>
      </tr>
      <tr>
        <td>新闻标题:</td>
        <td><input type="text" name="d_title" size="67" class="button1"></td>
      </tr>
      <tr>
        <td valign="top">图片附件:</td>
        <td><select name="d_picture" size="1"  style="background-color:#ecf3ff;"><option value=''>无</option></select> 
          <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"></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 type="text" name="d_from" size="67" class="button1"></td>
      </tr>
      <tr>
        <td>推荐新闻:</td>
        <td><input type="checkbox" name="d_special" value="1">是否特别新闻,如果是请打钩。</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 + -