Multi-value selection box issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a multi-value drop down box (<select name="Users" multiple>...)
When my form is posted, i can read Request.Form.Item("Users"), a string that
contains all values separated by comma. The problem is, that each value
itself can contain comma as well, in which case i have no way to separate my
values.
For example, my list box contains Smith, John and Cohen, David, two values.
When the selection box is posted, i am getting "Smith, John, Cohen, David",
no way to separate the values. Are there ways around?
Please help!
Julia
 
One option is to change the contents of the "value" attribute for each
<option> in the <select> to use a different character for the comma, and
simply doing a Replace() when you want to change it back

Of course, use the Split(strUsers, ",") array function to convert the
submitted string into something meaningful

Speaking of which, strictly speaking, you've made an error with your use of
the flag attribute "multiple"

Web Standards dictates that boolean attributes must be written as a regular
attribute

Therefore, your <select> tag becomes

(btw, it helps to keep form input names all lowercase)

<select name="users" multiple="mulitple"></select>

HTH
-W3bbo
 
Thanks for the response. Yes, I realize i can replace the characters myself,
this is kind of an artificial way around that requires changes in many
different places in my app. . I was hoping that there would be a more
ellegant way to handle this. In the classic asp I could read each value by
using Request.Form("users").Item(0), Request.Form("users").Item(1), etc., and
was hoping that something similar would be possible here.
 
Back
Top