如何将asp代码转换成js标准可调用的代码
是ASP转为JS代码,然后用<scriptlanguage="javascript"src="11.asp"></script>调到HTML页面上面<!--#includ...
是ASP转为JS代码,然后用<script language="javascript" src="11.asp"></script>调到HTML页面上面
<!--#include file="include/conn.asp"-->
<%
Dim Rs,sql
Set Rs=Server.CreateObject("adodb.recordset")
sql="select * from bigclass where bigclassid=1"
set rst=server.createobject("adodb.recordset")
Rs.open sql,conn,1,1
if Rs.eof then
Response.write("表没有数据")
else
bigclassid = rs("BigClassID")
bigclassname =rs("BigClassName")
Rs.close()
sql = "select top 6 * from news where BigClassName = '"&bigclassname&"'"
Rs.open sql,conn,1,1
do while not Rs.eof
response.Write""&rs("infotime")&" <a href=onews.asp?id="&rs("id")&" target=_blank>"&left(rs("Title"),13)&"...</a><br/>"
Rs.movenext
loop
end if
Rs.close()
Set Rs=nothing
%>
那位熟识ASP和JS代码的朋友帮我改改了··谢谢·· 展开
<!--#include file="include/conn.asp"-->
<%
Dim Rs,sql
Set Rs=Server.CreateObject("adodb.recordset")
sql="select * from bigclass where bigclassid=1"
set rst=server.createobject("adodb.recordset")
Rs.open sql,conn,1,1
if Rs.eof then
Response.write("表没有数据")
else
bigclassid = rs("BigClassID")
bigclassname =rs("BigClassName")
Rs.close()
sql = "select top 6 * from news where BigClassName = '"&bigclassname&"'"
Rs.open sql,conn,1,1
do while not Rs.eof
response.Write""&rs("infotime")&" <a href=onews.asp?id="&rs("id")&" target=_blank>"&left(rs("Title"),13)&"...</a><br/>"
Rs.movenext
loop
end if
Rs.close()
Set Rs=nothing
%>
那位熟识ASP和JS代码的朋友帮我改改了··谢谢·· 展开
展开全部
代码已经给你转换好了,但是没有经过测试(不好测试),按照你的想法可能是想把这段代码直接在客户端作为Javascript引用,如果真那样的话我想告诉你,这样是行不通的,使用<script/>标签引入的asp文件是已经在服务器端执行过的,如果下面的代码执行完后的结果不满足javascript的语法,就会出错!像这段代码使用<script src="11.asp"/>引入的话相当于下面“代码2”(位于最后面)的效果。
###############################################
## 代码1 ##
<!--#include file="include/conn.asp"-->
<%
var Rs,sql;
Rs=Server.CreateObject("ADODB.Recordset");
sql="select * from bigclass where bigclassid=1";
var rst=server.createobject("adodb.recordset");
Rs.open sql,conn,1,1;
if(Rs.Eof)
{
Response.Write("表没有数据");
}else{
bigclassid = Rs("BigClassID");
bigclassname =Rs("BigClassName");
Rs.close();
sql = "select top 6 * from news where BigClassName = '"&bigclassname&"'";
Rs.open sql,conn,1,1;
while(!Rs.Eof)
{
Response.Write(""+ rs("infotime") +"<a href=onews.asp?id="+ rs("id") +" target=_blank>"+ rs("Title").toString().substr(0,13) +"...</a><br/>";
Rs.MoveNext;
}
}
Rs.Close();
Rs=null;
%>
##############################################
## 代码2 ##
<script stype="javascript">
infotime<a href=onews.asp?id=001 target=_blank>title_001...</a><br/>";
infotime<a href=onews.asp?id=002 target=_blank>title_002...</a><br/>";
infotime<a href=onews.asp?id=003 target=_blank>title_003...</a><br/>";
</script>
或者是:
<script stype="javascript">
表没有数据
</script>
###############################################
## 代码1 ##
<!--#include file="include/conn.asp"-->
<%
var Rs,sql;
Rs=Server.CreateObject("ADODB.Recordset");
sql="select * from bigclass where bigclassid=1";
var rst=server.createobject("adodb.recordset");
Rs.open sql,conn,1,1;
if(Rs.Eof)
{
Response.Write("表没有数据");
}else{
bigclassid = Rs("BigClassID");
bigclassname =Rs("BigClassName");
Rs.close();
sql = "select top 6 * from news where BigClassName = '"&bigclassname&"'";
Rs.open sql,conn,1,1;
while(!Rs.Eof)
{
Response.Write(""+ rs("infotime") +"<a href=onews.asp?id="+ rs("id") +" target=_blank>"+ rs("Title").toString().substr(0,13) +"...</a><br/>";
Rs.MoveNext;
}
}
Rs.Close();
Rs=null;
%>
##############################################
## 代码2 ##
<script stype="javascript">
infotime<a href=onews.asp?id=001 target=_blank>title_001...</a><br/>";
infotime<a href=onews.asp?id=002 target=_blank>title_002...</a><br/>";
infotime<a href=onews.asp?id=003 target=_blank>title_003...</a><br/>";
</script>
或者是:
<script stype="javascript">
表没有数据
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询