首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

js和asp变量怎么互传

2013-07-08 
js和asp变量如何互传啊我有一个a.js文件和一个a.asp文件js文件中代码如下:numberparseInt(Math.random()*

js和asp变量如何互传啊
我有一个a.js文件和一个a.asp文件

js文件中代码如下:

number=parseInt(Math.random()*20)+1;

word="";

asp文件中代码如下:

?<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "englishword.mdb"
sql="SELECT * FROM cetsix WHERE ID="// 这里ID需要一个数
Set rs=conn.Execute(sql)

word=(rs("words"))
%>

cetsix是englishword.mdb数据库中的表,有ID和words两个字段

怎么把js文件中的number传给asp文件中的ID,asp文件中的得到的words值怎么传给js中的word

麻烦高手帮忙解决一下,不管用什么方法,给段代码,谢谢了
[解决办法]
js传给asp只有递交,用表单,url的querysring,ajax等都行。 
location.href = "a.asp?id=" + number;
asp中 <% id= Request("id") %>
-------
asp返回js

<%
Function escJS(s)
On Error Resume Next

s= Replace(s, "", "\")
s= Replace(s, """", """")
s= Replace(s, "'", "\'")
s= Replace(s, VbCrLf, "\n")
s= Replace(s, VbLf, "\n")
escJS= s
End Function

s = escJS(rs("words"))

%>
var word = "<%=s%>";

热点排行