JS调用数据库内容二级联动

来源:互联网 发布:小米手机mac地址怎么改 编辑:程序博客网 时间:2024/06/07 05:25

<!--#include Virtual ="/include/DBConn.asp"-->
<!--#include Virtual ="/include/Isenter.asp"-->
<%
NewsID=trim(request("Id"))
NewsID=replace(NewsID,"'","")

Sort_Id=trim(request("Sort_Id"))
Sort_Id=replace(Sort_Id,"'","")

set objRS = fSelect("Web_News","*","Id="&NewsID&"")
if objRS.eof then
%>
<script language=javascript>
     history.back();
     alert("ID号传送错误!");
</script>
<%
Response.End
end if

set bigClassrs = fSelect("Web_Sort","ID,[Name]","Lm_key=1") 
set SmallClassrs = fSelect("Web_Sort","ParentID,[Name],ID","Lm_key=2")
FirstID=""
FirstID=bigClassrs(0)
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/bodystyle.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
 font-size: 12px;
}
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
<link href="/webadmin/admin_main.css" rel="stylesheet" type="text/css">
<script language="javascript">
 function on_submit()
 {//验证数据的合法性   
 
 if (form1.smallclassID.value == "" || form1.smallclassID.value == "0")
    {
     alert("请选择您要二级栏目!");
     form1.smallclassID.focus();
     return false;
    }
   
    if (form1.Title.value == "")
    {
     alert("新闻标题不能为空!");
     form1.Title.focus();
     return false;
    }
   
    if (form1.Remark.value == "")
    {
     alert("关键字不能为空!");
     form1.Remark.focus();
     return false;
    } 
 change();    
 return true; 
}
function change()
{
document.getElementById("bigclassname").value = document.getElementById("bigClassID").options[document.getElementById("bigClassID").selectedIndex].text;
document.getElementById("smallclassname").value = document.getElementById("SmallClassID").options[document.getElementById("SmallClassID").selectedIndex].text;
}
</script>
</head>
<body>
<form name="form1" method="POST" action="ModifyNews3.asp" onSubmit="return on_submit()">
<table width="90%" border="0" align=center cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><b>修改新闻
      <input name="ID" type="hidden" id="ID" value="<%=NewsID%>">
      <input name="Sort_Id" type="hidden" id="Sort_Id" value="<%=Sort_Id%>">
    </b></td>
  </tr>
  <tr>
    <td colspan="3">
      <hr size="1">    </td>
  </tr>
  <tr>
    <td width="134" align="right">所属大类:</td>
    <td colspan="2">
   <%
      str=""
      str="<select name=""bigclassID"" class=""textbox"" id=""bigclassname"" onChange=redirect(this.options.value)>"  
      bigClassrs.movefirst
   if bigClassrs.eof then
      str=str&"<option value=""0"">没有类别设置</option>"
   else
     do until bigClassrs.eof 
      str=str&"<option value="&bigClassrs(0)&">"&bigClassrs(1)&"</option>"
      bigClassrs.movenext
     loop 
         str=str&"</select>" 
   end if
   response.Write(str)
  
  set bigClass = fSelect("VIEW_sort","ID,ParentID,Name,ParentName","Id="&Sort_Id&"")
  response.write("【"&bigClass(3)&"】")  
  
    %>
   <input name="bigclassname" type="hidden" value="<%=bigClass(3)%>">
    <%
    str=""
    str=str&"&nbsp;&nbsp;所属小类:<select name=""smallclassID"" class=""textbox"" id=""smallclassID"">"
       str=str&"<option value=""0"">请选择所属小类</option>"
  if FirstID<>"" then
      set SmallClassname = fSelect("Web_Sort","ParentID,[Name],ID","Lm_key=2 and ParentID="&FirstID&"")
   do until SmallClassname.eof
 
   str=str&"<option value="&SmallClassname(2)&">"&SmallClassname(1)&"</option>"  
   SmallClassname.movenext
   loop
   SmallClassname.close
   end if 
   str=str&"</select>"
   response.Write(str)
   %>
      <%response.write("【"&bigClass(2)&"】")%>
      <input name="smallclassname" type="hidden" value="<%=bigClass(2)%>"></td>
  </tr>
  <tr>
    <td width="134" align="right">新闻标题:</td>
    <td colspan="2"><input name="Title" type="text" class="textbox" value="<%response.write(objRS("Title"))%>" size="56"></td>
  </tr>
    <tr>
    <td width="134" align="right">是否显示:</td>
    <td width="186"><input name="is_show" type="radio" value="1" <%If objRS("Dis_Tag")=1 Then Response.Write("checked=checked")%>>
      是&nbsp;&nbsp;&nbsp;
        <input name="is_show" type="radio" value="0" <%If objRS("Dis_Tag")=0 Then Response.Write("checked=checked")%>>
      否</td>
    <td width="547">是否推荐:
      <input name="is_commend" type="radio" value="1" <%if objRS("Commend")=1 then response.write("checked=checked")%>>
是&nbsp;&nbsp;&nbsp;
<input type="radio" name="is_commend" value="0" <%if objRS("Commend")=0 then response.write("checked=checked")%>>
否</td>
    </tr>
  <tr>
    <td width="134" align="right">关键字:</td>
    <td colspan="2"><input name="Remark" type="text" class="textbox" id="Remark" value="<%response.write(objRS("Remark"))%>" size="56"></td>
  </tr>

  <tr>
    <td width="134" align="right">作者:</td>
    <td colspan="2"><input name="Author" type="text" class="textbox" value="<%response.write(objRS("Author"))%>" size="20"></td>
  </tr>
  <tr>
    <td width="134" align="right">来源:</td>
    <td colspan="2"><input name="Source" type="text" class="textbox" id="Source" value="<%response.write(objRS("Source"))%>" size="20"></td>
  </tr>
  <tr>
    <td valign="top" width="134" align="right">新闻内容:</td>
    <td colspan="2"><textarea name="Content" style="display:none"><%response.write(objRS("Content"))%></textarea>
    <iframe src="webedit/ewebeditor.asp?id=Content&style=webedit" width="600" HEIGHT="350" scrolling="no" frameborder="0" class="textboxLINE_1" ID="eWebEditor1"></iframe> </td>
  </tr>
  <tr>
    <td width="134"></td>
    <td colspan="2"></td>
  </tr>
  <tr>
    <td colspan=3><hr size=1></td>
  </tr>
  <tr>
    <td colspan="3" align="center"><input name="B1" type="submit" class="Bbutton" value=" 修改&gt;&gt; ">
      &nbsp;&nbsp;
      <input name="Submit" type="reset" class="Bbutton" value="  重置&gt;&gt;">
      &nbsp;&nbsp;</td>
  </tr>
</table>
<%
bigClass.close
objRS.close
%>
</form>
<script>
<!--
var temp=document.form1.smallclassID
function redirect(x)
{
var i
i=0
for (var m=temp.options.length-1;m>0;m--)
temp.options[m]=null
<%
while not SmallClassrs.eof
%>
cnt=<%=SmallClassrs(0)%>
if(cnt==x)
{
temp.options[i]=new Option("<%=SmallClassrs(1)%>","<%=SmallClassrs(2)%>")
i=i+1}
else
{
temp.options[i]=null
}
<%
SmallClassrs.movenext
wend
%>
}
//-->
</script>
</body>
</html> 

原创粉丝点击