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 26 32026
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... 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
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... 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
of course that should read
myarray=split(Request.Form("ListBox"),",")
soz
"UncleWobbly" <he***@talk21.com> wrote in message
news:40*********************@lovejoy.zen.co.uk... 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... 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
While admittedly Ray's solution is the correct one. If you are just putting
them in a table, you could do something like....
<table>
<tr>
<%
sVal=Request.Form("Listbox")
Response.Write "<td>" & Replace(sVal,", ","</td><td>") & "</td>"
%>
</tr>
</table>
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2****************@TK2MSFTNGP11.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... 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
What I'm wondering is if the separator is done by the server or if the
browser chooses the delimiter and posts the data with it. I ~believe~ that
the browser submits data like:
select=a&select=b&select=c, etc. and it's the ASP process that returns that
as comma+space delimited values.
Ray at work
"Roland Hall" <nobody@nowhere> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl... "UncleWobbly" wrote: : of course that should read : : myarray=split(Request.Form("ListBox"),",")
or: myarray=split(Request.Form("ListBox"),", ") ...if there is actually a space in it as Ray mentioned.
-- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... "Christina" <ha********@hotmail.con> wrote in message news:eN**************@TK2MSFTNGP09.phx.gbl... 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
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
I believe Request.Form(Key) is already an array (sort of):
<%
Dim i,iMax
iMax = Request.Form("test").Count
For i = 1 To iMax
Response.Write Request.Form("test")(i) & "<br>"
Next
%>
<form method="post">
<select name="test" multiple="multiple">
<option value="apple">apple</option>
<option value="banana">banana</option>
<option value="cranberry">cranberry</option>
<option value="danish">danish</option>
<option value="egg">egg</option>
</select>
<input type="Submit">
</form>
The documentation states as much. However, what is not made clear is
that there is an implicit translation to a string when a form variable
is referenced. As such the following fails with a type mismatch:
UBound(Request.Form("test"))
Here's a link to the documentation: http://msdn.microsoft.com/library/en...bom_reqocf.asp
HTH
-Chris
play safe and trim the items in the array as they are used :o)
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:ez**************@TK2MSFTNGP11.phx.gbl... What I'm wondering is if the separator is done by the server or if the browser chooses the delimiter and posts the data with it. I ~believe~
that the browser submits data like:
select=a&select=b&select=c, etc. and it's the ASP process that returns
that as comma+space delimited values.
Ray at work
"Roland Hall" <nobody@nowhere> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl... "UncleWobbly" wrote: : of course that should read : : myarray=split(Request.Form("ListBox"),",")
or: myarray=split(Request.Form("ListBox"),", ") ...if there is actually a space in it as Ray mentioned.
-- Roland Hall /* This information is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
Actually, I think I now prefer the method Chris posted, because if one of
your option values is "B, C" that'll be split. I am so finished with
splitting multi-element form controls! :]
Ray at work
"UncleWobbly" <he***@talk21.com> wrote in message
news:40***********************@lovejoy.zen.co.uk.. . play safe and trim the items in the array as they are used :o)
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:ez**************@TK2MSFTNGP11.phx.gbl... What I'm wondering is if the separator is done by the server or if the browser chooses the delimiter and posts the data with it. I ~believe~ that the browser submits data like:
select=a&select=b&select=c, etc. and it's the ASP process that returns that as comma+space delimited values.
Ray at work
"Roland Hall" <nobody@nowhere> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl... "UncleWobbly" wrote: : of course that should read : : myarray=split(Request.Form("ListBox"),",")
or: myarray=split(Request.Form("ListBox"),", ") ...if there is actually a space in it as Ray mentioned.
-- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
Thank you all for good help!! :)
This worked:
myArray = Request.Form("ListBox").Split(",")
For i = 0 To UBound(myArray)
Response.Write(myArray.GetValue(i))
Next
Hugs,
Christina
"Christina" <ha********@hotmail.con> wrote in message
news:eN**************@TK2MSFTNGP09.phx.gbl... 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
Hello Christina,
I don't know in what environment you are programming but you might be able to use this HTML and JavaScript code to show how to separate the comma separated list into an array. The split() method creates an array of elements from a String object by using the delimiter specified in its parameter. The code may not be perfect because I wrote it during my computer lab class in college so maybe there can be some improvements. I am just showing you an idea. Use the array then to fill up a table.
Signed,
BusyMan
CODE******************************************
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
var sampleText="red,green,blue,violet";
function getWords() {
var input = sampleText.split(",");
var input2 = new String();
for (var i = 0; i<input.length; i++) {
input2 += input[i] + "<BR>";
}
document.all("HERE").innerHTML = input2;
}
</SCRIPT>
</HEAD>
<BODY onLoad="getWords()">
<SPAN ID="HERE"></SPAN>
</BODY>
</HTML>
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
:o))))))))))))))))))))
none of thought of that one!!!
LOL!
"Christina" <ha********@hotmail.con> wrote in message
news:ug**************@TK2MSFTNGP11.phx.gbl... Thank you all for good help!! :) This worked:
myArray = Request.Form("ListBox").Split(",") For i = 0 To UBound(myArray) Response.Write(myArray.GetValue(i)) Next
Hugs, Christina
"Christina" <ha********@hotmail.con> wrote in message news:eN**************@TK2MSFTNGP09.phx.gbl... 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
:o)
not yet you aren't... see Christina's final solution :o)
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:ul**************@TK2MSFTNGP12.phx.gbl... Actually, I think I now prefer the method Chris posted, because if one of your option values is "B, C" that'll be split. I am so finished with splitting multi-element form controls! :]
Ray at work
"UncleWobbly" <he***@talk21.com> wrote in message news:40***********************@lovejoy.zen.co.uk.. . play safe and trim the items in the array as they are used :o)
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:ez**************@TK2MSFTNGP11.phx.gbl... What I'm wondering is if the separator is done by the server or if the browser chooses the delimiter and posts the data with it. I ~believe~ that the browser submits data like:
select=a&select=b&select=c, etc. and it's the ASP process that returns that as comma+space delimited values.
Ray at work
"Roland Hall" <nobody@nowhere> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl... > "UncleWobbly" wrote: > : of course that should read > : > : myarray=split(Request.Form("ListBox"),",") > > or: > myarray=split(Request.Form("ListBox"),", ") > ...if there is actually a space in it as Ray mentioned. > > -- > Roland Hall > /* This information is distributed in the hope that it will be
useful, but > without any warranty; without even the implied warranty of merchantability > or fitness for a particular purpose. */ > Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/ > WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp > MSDN Library - http://msdn.microsoft.com/library/default.asp > >
"Christina" <ha********@hotmail.con> wrote in message
news:ug**************@TK2MSFTNGP11.phx.gbl... This worked:
myArray = Request.Form("ListBox").Split(",") For i = 0 To UBound(myArray) Response.Write(myArray.GetValue(i)) Next
That worked? What language is this? VBJscript? ? ? ?
Ray at work
Christina wrote: Thank you all for good help!! :) This worked:
????
How could this possibly work? myArray = Request.Form("ListBox").Split(",")
A JScript function, Split(), followed by
For i = 0 To UBound(myArray)
A vbcript-style loop through an array using a vbscript function, ubound()
followed by
Response.Write(myArray.GetValue(i))
another jscript function, GetValue(), which is syntactically incorrect
(getValue() is correct) to get the value of the array element!
Next
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
On Thu, 29 Jan 2004 15:58:31 -0500, "Ray at <%=sLocation%> [MVP]"
<myfirstname at lane34 dot com> wrote: "Christina" <ha********@hotmail.con> wrote in message news:ug**************@TK2MSFTNGP11.phx.gbl...
This worked:
myArray = Request.Form("ListBox").Split(",") For i = 0 To UBound(myArray) Response.Write(myArray.GetValue(i)) Next
That worked? What language is this? VBJscript? ? ? ?
Now if there were a VBPB&Jscript that would also trim the cursts I'd
be impressed... :)
Actually, I am impressed with Christina's solution. I don't know
enough to say why it works, but it opens possibilities I hadn't
considered before. Good work.
Jeff
"Jeff Cochran" <jc*************@naplesgov.com> wrote in message
news:40***************@msnews.microsoft.com... Actually, I am impressed with Christina's solution. I don't know enough to say why it works, but it opens possibilities I hadn't considered before.
What is going on here? Since when does request.form have a split method?
Is today April 1st? Did I miss a post somewhere or something?
Ray at work
On Thu, 29 Jan 2004 16:30:56 -0500, "Ray at <%=sLocation%> [MVP]"
<myfirstname at lane34 dot com> wrote: "Jeff Cochran" <jc*************@naplesgov.com> wrote in message news:40***************@msnews.microsoft.com...
Actually, I am impressed with Christina's solution. I don't know enough to say why it works, but it opens possibilities I hadn't considered before.
What is going on here? Since when does request.form have a split method? Is today April 1st? Did I miss a post somewhere or something?
It doesn't. Which is kinda the beauty of it. It uses a method that
isn't there. Very Zen. Hmmm... Don't code the method, *Be* the
method... :)
Nuts, you're right. It isn't April 1...
Jeff
"Christina" <ha********@hotmail.con> wrote in message
news:ug**************@TK2MSFTNGP11.phx.gbl...
: Thank you all for good help!! :)
: This worked:
:
: myArray = Request.Form("ListBox").Split(",")
: For i = 0 To UBound(myArray)
: Response.Write(myArray.GetValue(i))
: Next
It's a new language, all it's own. (see undocumented feature set)
What will Christina come up with next? (O:=
Roland (confused - as I should be)
"Bob Barrows" wrote: myArray = Request.Form("ListBox").Split(",")
A JScript function, Split(), followed by
Unless [Split] is a method of the Request.Form object, even JScript won't
like this, though JScript will certainly be happy with
myArray = Request.Form("ListBox").Item.split(",")
....since R.F().Item is a string value.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
It seems to me that it works like this: request.form("x") returns a
string. The string has the split method.
-rwg
This is what I think, not necessarily what is right
In jscript, strings are objects and have methods. In VBscript, they do not.
The code she posted had a mixture of vbscript and jscript and some third
language I've never seen.
Ray at work
"Rob Greene" <a-****@online.microsoft.com> wrote in message
news:$%****************@cpmsftngxa07.phx.gbl... It seems to me that it works like this: request.form("x") returns a string. The string has the split method.
-rwg This is what I think, not necessarily what is right
"Rob Greene" wrote: It seems to me that it works like this: request.form("x") returns a string. The string has the split method.
Request.Form("x") is not a string value, nor a String Object. It is an
object with properties .Key, .Count and .Item. It has no native .Split()
method.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Dave Anderson wrote on 02 feb 2004 in
microsoft.public.inetserver.asp.general: "Rob Greene" wrote: It seems to me that it works like this: request.form("x") returns a string. The string has the split method.
Request.Form("x") is not a string value, nor a String Object. It is an object with properties .Key, .Count and .Item. It has no native .Split() method.
So:
arr = request.form("x").item.split(",")
?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl... "Rob Greene" wrote: It seems to me that it works like this: request.form("x") returns a string. The string has the split method. Request.Form("x") is not a string value, nor a String Object. It is an object with properties .Key, .Count and .Item. It has no native
..Split() method.
I don't believe that Request.Form("x") supports the Key property. The
Request object is immutable.
-Chris Hohmann
"Evertjan." wrote: arr = request.form("x").item.split(",")
?
JScript is case sensitive. That should be
Request.Form("x").Item.split(",")
And if you're unsure if there will even be a name-value pair for "x", you
can use this:
(Request.Form("x").Item || "").split(",")
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: middletree |
last post by:
I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the form is
submitted. I have a field called EmailSentTo, and if...
|
by: Morris |
last post by:
This may not be possible on the server side, so apologies if this is the
wrong group for this post.
My form consists of an unknown number of pairs of text boxes. They are
named textbox_a and...
|
by: Derek |
last post by:
I came upon the idea of writting a logging class that
uses a Python-ish syntax that's easy on the eyes (IMO):
int x = 1;
double y = 2.5;
std::string z = "result";
debug = "Results:", x, y,...
|
by: Toby Newman |
last post by:
At the page:
http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000
or
http://tinyurl.com/4ptzs
the author warns:
"The for loop is frequently used, usually...
|
by: Avi |
last post by:
I need to create a text file that has the data from the 10 tables in
the database. The number of fields in the tables exceeds 255 and so I
cannot make a new table with all the fields and then...
|
by: ILCSP |
last post by:
Hi, I have a sql table containing the answers for some tests. The
information in this table is presented vertically and I need to create
strings with them. I know how to read the data in VB.Net...
|
by: Drum2001 |
last post by:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.
Example:
Show me all names where...
|
by: hprYeV |
last post by:
I have done a reasonable amount of programming in C++,
but the other day I was talking to someone after a
lecture in a course on Java who said that they had not been
used to the syntax of the Java...
|
by: silverburgh.meryl |
last post by:
Hi,
I need some help in understanding the following for() loop:
for (PRBool isRoot;
mCSSUtils->IsRuleNodeRoot(ruleNode, &isRoot), !isRoot;
mCSSUtils->GetRuleNodeParent(ruleNode, &ruleNode))
...
|
by: anfetienne |
last post by:
hi im back again.......i have a code to create strings and save it within a text file to pass variables to flash. im using the string format below.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |