现在我有一个变量为ss
我想把文件名ss这个变量取得的值组成一个数组然后再把它传给session
最后实现把文件名全部列出来
有点象购物袋的样子
高手们能告诉我吗?
在给SS赋值的时候,文件名之间用;隔开,最后:
aa=split(session("ss"),";")
for i=0 to ubound(aa)
response.write aa(i)
next
首先定义一个数组变量
ss=request("ss")
dim filename
redim filename(0)
filename(0)=id
if session("first")="" then
session("first")="have"
session("filename")=filename
end if
response.write "<br>"&ubound(session("filename"))
filename=session("filename")
redim preserve filename(ubound(session("filename"))+1)
filename(ubound(session("filename"))+1)=ss
session("filename")=filename
for i=0 to ubound(session("filename"))
response.write "<font color=red><br>a"&session("filename")(i)&"</font>"
next
aa为数组
把aa存到session中:session("buy")=aa
在其他页面用该数组:
bb=session("buy")
for i=0 to Ubound(bb)
Response.Write bb(i)
next
用一個分隔符,一般用別人不會用到的,如&*&來分隔,你將每次取的值加到session變量中時用分隔符分隔起來,然後split(session變量,"&*&"),再用for i=0 to ubound(session變量arr)就行了
<%
dim a()
redim a(4)
a(1)="1"
a(2)="2"
a(3)="3"
session("aa")=a
用时把session的值传给一个数组
b=session("aa")
for i=1 to 4
response.write b(i)
next
%>
运行结果:123
给你一个没有重复的
ss=obj.savefile("file1")
dim filename
dim add
add=true
redim filename(0)
filename(0)=id
if session("first")="" then
session("first")="have"
session("filename")=filename
end if
response.write "<br>"&ubound(session("filename"))
filename=session("filename")
for i=0 to ubound(session("filename"))
if session("filename")(i)=id then
add=false
exit for
end if
next
if add then
redim preserve filename(ubound(session("filename"))+1)
filename(ubound(session("filename"))+1)=ss
session("filename")=filename
end if
for i=0 to ubound(session("filename"))
response.write "<font color=red><br>a"&session("filename")(i)&"</font>"
next
filename=obj.savefile("file1")
if trim(session("filename"))="" or isnull(session("filename"))=true then为空直接添加
session("filename")=filename
elseif instr(session("filename"),"$") then说明session中有两个以上文件名
if instr(session("filename"),filename)=0 then判断所选文件是否已经存在
session("filename")=session("filename")&"$"&filename不存在则添入session("filename")中
end if
end if
printf session("filename")
dim Arr
Arr=split(session("filename"),"$",-1,1)
for i=0 to Ubound(Arr)
response.write "File["& i &"]="&Arr(i)&"<br>"
next