<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="inc/seeion.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="fckeditor/fckeditor.asp"-->
<%
Dim rs, i, main_id, sql
If request.Form("submit") = "确认添加" Then
    If request.Form("news_name") = "" Then
        Call infoback("新闻名称不能为空！")
    End If
    If request.Form("news_content") = "" Then
        Call infoback("详细介绍不能为空！")
    End If
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from news"
    rs.Open sql, conn, 1, 3
    rs.addnew
    rs("news_name") = request.Form("news_name")
    rs("news_sources") = request.Form("news_sources")
    rs("news_author") = request.Form("news_author")
    rs("main_id") = request.Form("main_id")
    rs("sub_id") = request.Form("sub_id")
    rs("uploadfile") = request.Form("uploadfile")
    rs("news_keywords") = request.Form("news_keywords")

    If request.Form("news_rec") = "" Then
        rs("news_rec") = False
    Else
        rs("news_rec") = request.Form("news_rec")
    End If

    If request.Form("news_hot") = "" Then
        rs("news_hot") = False
    Else
        rs("news_hot") = request.Form("news_hot")
    End If

    If request.Form("news_top") = "" Then
        rs("news_top") = False
    Else
        rs("news_top") = request.Form("news_top")
    End If

    rs("news_content") = request.Form("news_content")
    rs.update
    Call close_rs
    Call close_conn
    Call infohref("新闻添加成功！点击确认继续添加！", "news.asp")
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网站后台管理系统</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language = "JavaScript">
<%
Set Rs = Server.CreateObject("Adodb.Recordset")
Rs.Open "select sub_title,sub_id,main_id from SmallClass_New order by order_id", conn, 1, 1
%>
var onecount;
onecount=0;
subcat = new Array();
<%
i = 0
Do While Not Rs.EOF
%>
subcat[<%=i%>] = new Array("<%= Trim(Rs("sub_title"))%>","<%= Rs("main_id")%>","<%= Rs("sub_id")%>");
<%
i = i + 1
Rs.MoveNext
Loop
Rs.Close
Set rs = Nothing
%>
onecount=<%=i%>;
function changelocation(locationid,formname)
    {
    formname.sub_id.length = 0;
    var i;
    for (i = 0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
             formname.sub_id.options[formname.sub_id.length] = new Option(subcat[i][0], subcat[i][2]);
            }
        }
    }
</script>
</head>
<body>
<!--#include file="inc/header.asp"-->
<div id="top_banner" class="layout"></div>
<div id="content" class="layout">
  <!--#include file="inc/left.asp"-->
  <div id="right">
    <div class="right_title">
      <h2>添加新闻</h2>
    </div>
    <div class="right_body">
      <table width="100%" align="center">
        <form name="cherry" method="post">
          <tr>
            <td width="68" align="right">新闻名称：</td>
            <td width="696"><input type="text" onblur='value=value.replace(/[>"<]/g,"")' name="news_name" size="50" />
              <span class="red">必填</span></td>
          </tr>
          <tr>
            <td width="68" align="right">新闻来源：</td>
            <td><input type="text" name="news_sources" size="40" value="本站" onfocus="if (value =='本站'){value =''}" onblur="if (value ==''){value='本站'}" /></td>
          </tr>
          <tr>
            <td width="68" align="right">新闻作者：</td>
            <td><input type="text" name="news_author" size="20" value="Cherry" onfocus="if (value =='匿名'){value =''}" onblur="if (value ==''){value='匿名'}" /></td>
          </tr>
          <tr>
            <td align="right">所属分类：</td>
            <td><select name="main_id" id="main_id" onChange="changelocation(document.cherry.main_id.options[document.cherry.main_id.selectedIndex].value,document.cherry)" >
                <%
i = 0
Set rs = Conn.Execute("select main_id,main_title from BigClass_New order by order_id")
Do While Not rs.EOF
    If i = 0 Then main_id = rs(0)
    Response.Write("<option value="""&rs(0)&""">"&rs(1)&"</option>")
    i = i + 1
    rs.movenext
Loop
Set rs = Nothing
%>
              </select>
              <select name="sub_id" id="sub_id">
              </select></td>
            <script type="text/javascript">
            if (document.cherry.main_id.length>0)
			{
				changelocation(document.cherry.main_id.options[0].value,document.cherry);
				}
            </script>
          </tr>
          <tr>
            <td rowspan="2" align="right">图片标题：</td>
            <td><input type="text" name="uploadfile" size="40" />
              <span class="red">选填</span></td>
          </tr>
          <tr>
            <td><iframe src="upload.asp" width="600" height="25" scrolling="auto" frameborder="0"></iframe></td>
          </tr>
          <tr>
            <td align="right">关键字：</td>
            <td><input type="text" name="news_keywords" size="100"/></td>
          </tr>
          <tr>
            <td align="right">属性：</td>
            <td>推荐
              <input type="checkbox" name="news_rec" value="true" />
              热点
              <input type="checkbox" name="news_hot" value="true" />
               置顶
              <input type="checkbox" name="news_top" value="true" /></td>
          </tr>
          <tr>
            <td align="right">详细介绍：</td>
            <td><%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "fckeditor/"
oFCKeditor.ToolbarSet = "Default"
oFCKeditor.Width = "100%"
oFCKeditor.Height = "335"
oFCKeditor.Value = ""
oFCKeditor.Create "news_content"
%></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input type="submit" name="submit" class="submit_button" value="确认添加" /></td>
          </tr>
        </form>
      </table>
    </div>
  </div>
  <div class="clear"></div>
</div>
<!--#include file="inc/footer.asp"-->
