asp代码在<%@ Language=JavaScript %>页面如何写

xiejunhua 2004-04-30 11:22:48
user=Session("user_name")
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select cid from table1 where pay='Y' and user='"& user &"'"
rs.Open sql,Cnndb,3,1
while not rs.eof
CString=CString & ","&trim(rsn("cid"))
rsn.movenext
wend
rs.close
set rs=nothing
Session("Cstr")=CString
改在
<%@ Language=JavaScript %>页面
var user=Session("user_name");
var rs=Server.CreateObject ("adodb.recordset");
var sql="select * from table1 where user='"+user+"'";

之后循环取值组成字符串如何写呀?
...全文
52 5 点赞 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xiejunhua 2004-04-30
谢谢!
  • 打赏
  • 举报
回复
wanghr100 2004-04-30
<%
var CString = "";
var user=Session("user_name");
var rs = Server.CreateObject("ADODB.Recordset");
var sql="select cid from table1 where pay='Y' and user='"+ user +"'";
rs.Open(sql,Cnndb,3,1)
while(!rs.eof){
CString += "," + String(rs("cid")).trim();
rs.MoveNext();
}
rs.close();
delete rs;
Session("Cstr")=CString;

//JavaScript没有trim方法.自己定义.
//调用str.trim() 去掉左右的空格.
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
%>
  • 打赏
  • 举报
回复
wanghr100 2004-04-30
Try..

<%@ Language=JavaScript %>
<%
var user=Session("user_name");
var rs = Server.CreateObject("ADODB.Recordset");
var sql="select cid from table1 where pay='Y' and user='"+ user +"'";
rs.Open(sql,Cnndb,3,1)
while(!rs.eof){
CString = CString + "," + rs("cid").trim()
rs.MoveNext();
}
rs.close();
delete rs;
Session("Cstr")=CString;

//JavaScript没有trim方法.自己定义.
//调用str.trim() 去掉左右的空格.
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
%>
  • 打赏
  • 举报
回复
fason 2004-04-30
var CString = "";
while(!rs.eof){
CString+= (","+String(rsn("cid")));
rsn.movenext;
}
rs.Close();
rs=null
Session("Cstr")=CString;
  • 打赏
  • 举报
回复
xiejunhua 2004-04-30
有人帮忙吗?
  • 打赏
  • 举报
回复
相关推荐
发帖
JavaScript
加入

8.5w+

社区成员

Web 开发 JavaScript
申请成为版主
帖子事件
创建了帖子
2004-04-30 11:22
社区公告
暂无公告