ASP新聞欄目切換+JS

來源:互聯網
上載者:User

<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from kml_sclass"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(rs("sclassname"))%>","<%= trim(rs("bclassid"))%>","<%= trim(rs("sclassid"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        %>
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.sclassid.length = 0;

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
              document.myform.sclassid.options[document.myform.sclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }       
        }
       
    }   
</script>
</head>
<body>
<br>
<form name="myform" method="post" action="?action=addsave">
<table width="80%"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  <tr bgcolor="#F6F6F6">
    <td height="25" colspan="2"><div align="center"><strong>修 改 新 聞</strong></div></td>
  </tr><tr bgcolor="#F6F6F6"><td align="center" height="25">新聞樣式:</td><td><input name="jibie" type="radio" value="0" checked>
          中文版</td></tr>
  <tr>
    <td width="15%" height="25" align="right" bgcolor="#F6F6F6">文章類型:</td>
    <td width="85%" bgcolor="#FFFFFF">
<%
    sql = "select * from kml_bclass"
    rs.open sql,conn,1,1
 if rs.eof and rs.bof then
 response.write "請先添加欄目。"
 response.end
 else
%>
<select name="bclassid" onChange="changelocation(document.myform.bclassid.options[document.myform.bclassid.selectedIndex].value)" size="1">
        <option selected value="<%=trim(rs("bclassid"))%>"><%=trim(rs("bclassname"))%></option>
        <%dim selclass
         selclass=rs("bclassid")
        rs.movenext
        do while not rs.eof
%>
<option value="<%=trim(rs("bclassid"))%>"><%=trim(rs("bclassname"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
      </select>
      <select name="sclassid">
<%
sql="select * from kml_sclass where bclassid="&selclass
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
        <option selected value="<%=rs("sclassID")%>"><%=rs("sclassname")%></option>
<%
rs.movenext
do while not rs.eof
%>
<option <%if RsEdit("sclassid")=rs("sclassID") then %> selected <% end if %>value="<%=rs("sclassID")%>"><%=rs("sclassname")%></option>
<%
rs.movenext
loop
end if
        rs.close
        set rs = nothing
%>
</select>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.