如何循环逗号分隔列表? [英] How do I loop through a comma-separated list?

查看:93
本文介绍了如何循环逗号分隔列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个所选项目的列表框的帖子。当

将表单发布到服务器ASP文件时,我想循环遍历

所选项目,将每个项目插入到表格中。我该怎么做?


如果我执行该行:

Response.Write(Request.Form(" ListBox"))),
我得到所选值的列表,用逗号分隔。

Christina

I have a post-form that holds a listbox with mulitple selected items. When
the form is posted to the server ASP file, I want to loop through the
selected items, to insert each of them into a table. How do I do that?

If I execute the line:
Response.Write(Request.Form("ListBox")),
I get the list of selected values, separated by commas.
Christina

推荐答案

如果你那么将该列表拆分为一个数组,然后只需要一个简单的循环即可获得所有:


myarray = split(Request.Form(") ListBox))


for n = 0 to ubound(myarray)

''...现在每个项目都被访问为;

myarray(n)

next

" Christina" <公顷******** @ hotmail.con>在消息中写道

新闻:eN ************** @ TK2MSFTNGP09.phx.gbl ...
if you then split that list into an array yo then only need a simple loop to
grab ''em all:

myarray=split(Request.Form("ListBox"))

for n=0 to ubound(myarray)
'' ... now each of the items is accessed as ;
myarray(n)
next
"Christina" <ha********@hotmail.con> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
我有一个帖子包含多个所选项目的列表框的表单。当表单发布到服务器ASP文件时,我想遍历
所选项目,将每个项目插入到表格中。我该怎么做?

如果我执行该行:
Response.Write(Request.Form(" ListBox"))),
我得到所选值的列表,以逗号分隔。

Christina
I have a post-form that holds a listbox with mulitple selected items. When
the form is posted to the server ASP file, I want to loop through the
selected items, to insert each of them into a table. How do I do that?

If I execute the line:
Response.Write(Request.Form("ListBox")),
I get the list of selected values, separated by commas.
Christina



我相信这些项目可能用逗号分隔空间

实际上,是吗?你要做的是创建一个数组。


<%

sVal = Request.Form(" Listbox")

''''sVal =" Joe,Bob,Tom,Phil,Toby"为了论证的缘故


ArrayOfValues = Split(sVal,",")

For i = 0 To UBound(ArrayOfValues )

Response.Write" Value" &安培;我和我"是 &安培; ArrayOfValues(i)& < br>"

下一页

%>


雷在工作


" Christina" <公顷******** @ hotmail.con>在消息中写道

新闻:eN ************** @ TK2MSFTNGP09.phx.gbl ...
I believe that the items are probably separated by a comma and a space
actually, yes? What you''d want to do is create an array.

<%
sVal = Request.Form("Listbox")
''''sVal = "Joe, Bob, Tom, Phil, Toby" for argument''s sake

ArrayOfValues = Split(sVal, ", ")

For i = 0 To UBound(ArrayOfValues)
Response.Write "Value " & i & " is " & ArrayOfValues(i) & "<br>"
Next
%>

Ray at work


"Christina" <ha********@hotmail.con> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
我有一个帖子包含多个所选项目的列表框的表单。当表单发布到服务器ASP文件时,我想遍历
所选项目,将每个项目插入到表格中。我该怎么做?

如果我执行该行:
Response.Write(Request.Form(" ListBox"))),
我得到所选值的列表,以逗号分隔。

克里斯蒂娜
I have a post-form that holds a listbox with mulitple selected items. When
the form is posted to the server ASP file, I want to loop through the
selected items, to insert each of them into a table. How do I do that?

If I execute the line:
Response.Write(Request.Form("ListBox")),
I get the list of selected values, separated by commas.
Christina



当然应该阅读


myarray = split(Request.Form(" ListBox"),",")


soz


" ; UncleWobbly" <他*** @ talk21.com>在消息中写道

新闻:40 ********************* @ lovejoy.zen.co.uk ...
of course that should read

myarray=split(Request.Form("ListBox"),",")

soz

"UncleWobbly" <he***@talk21.com> wrote in message
news:40*********************@lovejoy.zen.co.uk...
如果你然后将该列表拆分成一个数组,那么只需要一个简单的循环
就可以全部抓住它们:

myarray = split(Request.Form(" ListBox") ;))

对于n = 0到ubound(myarray)
''...现在每个项目都被访问为;
myarray(n)
下一页

" Christina" <公顷******** @ hotmail.con>在消息中写道
新闻:eN ************** @ TK2MSFTNGP09.phx.gbl ...
if you then split that list into an array yo then only need a simple loop to grab ''em all:

myarray=split(Request.Form("ListBox"))

for n=0 to ubound(myarray)
'' ... now each of the items is accessed as ;
myarray(n)
next
"Christina" <ha********@hotmail.con> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl...
我有一个包含一个帖子的帖子包含多个所选项目的列表框。
当表单发布到服务器ASP文件时,我想遍历
所选项目,将每个项目插入到表格中。我该怎么做?

如果我执行该行:
Response.Write(Request.Form(" ListBox"))),
我得到所选值的列表,以逗号分隔。

Christina
I have a post-form that holds a listbox with mulitple selected items. When the form is posted to the server ASP file, I want to loop through the
selected items, to insert each of them into a table. How do I do that?

If I execute the line:
Response.Write(Request.Form("ListBox")),
I get the list of selected values, separated by commas.
Christina




这篇关于如何循环逗号分隔列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆