Connecting Tech Pros Worldwide Forums | Help | Site Map

Passing COMBO box values from 1 ASP page to another!

Newbie
 
Join Date: Sep 2007
Posts: 15
#1: Sep 15 '09
Hey all,

Alright. So I have this "Combobox" in an ASP page (a box which allows multiple selection using the CTRL key) and I am trying to pass the values selected from it into another ASP page using the GET method. Interestingly, when I catch it in the next page and use the "Response.Write" to print it on the screen it prints OK. But when I try to store that same variable in a Text Box it only stores the first word!

Let me elaborate. So lets assume there is a combo box with the following choices selected on WELCOME.ASP. The variable name for this com,bo box is sNames. Screenshot below.


Now, on the SUBMIT.ASP page, I am using the following to capture this information.


And you will notice, that the Response.Write shows it like this:


Now, I try to copy the same info. into a TEXTBOX. But it only catches the first WORD of that sequence!


Could you please tell me what I am doing wrong? How can I capture every name that was chosen in the combo into this text box?

Thanks.

KS

Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#2: Sep 15 '09

re: Passing COMBO box values from 1 ASP page to another!


Try putting quotes around the value for the "value" property of the textbox...hmm that's hard to explain.

For example:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" size="42" value="<%= sNames %>" />
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Sep 16 '09

re: Passing COMBO box values from 1 ASP page to another!


try putting it in a textarea ranther than a textbox. I bet there are hard returns between the values, a textbox might have trouble with that.

Frinny's suggestion should work as well.

Jared
Newbie
 
Join Date: Sep 2007
Posts: 15
#4: Sep 16 '09

re: Passing COMBO box values from 1 ASP page to another!


Quote:

Originally Posted by Frinavale View Post

Try putting quotes around the value for the "value" property of the textbox...hmm that's hard to explain.

For example:

Expand|Select|Wrap|Line Numbers
  1. <input type="text" size="42" value="<%= sNames %>" />

Yes. :) This works absolutely fine. Thank you so much.

Now - another small add on question. How do I now transfer this value from the textbox and figure out how many 'commas' (,) this word collection has? The idea is that if something like "John Smith, Gerry Kaine, Jennifer Hilton" is stored, then I should be able to put a loop or some such to figure out how many commas are in that expression. Can we do that using the code I have?

Kindly advise. Much appreciated.

Cheers,

KS
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#5: Sep 16 '09

re: Passing COMBO box values from 1 ASP page to another!


I'm sorry but I don't have a lot of experience using the same type of server-side code that you're using....I hope what I'm about to suggest is valid (I think it should be). Jhardman please feel free to correct me at any time....

The value passed to you is a string that is "delimited" (separated) by the "," character.

To keep things simple you could split this string on the "," using the String.Split() method. The String.Split() method returns an array of strings.

For example if you had a string like:
Expand|Select|Wrap|Line Numbers
  1. Dim myString = "John Smith, Gerry Kaine, Jennifer Hilton"
And you used the String.Split(",") method:
Expand|Select|Wrap|Line Numbers
  1. Dim names() = myString.Split(",")
The names array would be as follows:
["John Smith", "Gerry Kaine", "Jennifer Hilton"]

Note how there is no ","s in the array...just the values that were separated by the commas.

Now you can use that array to do further manipulations on the names in the array.

-Frinny
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#6: Sep 16 '09

re: Passing COMBO box values from 1 ASP page to another!


That's what I would suggest too, but the syntax in VBScript is
Expand|Select|Wrap|Line Numbers
  1. dim names
  2. names = split(sNames, ",")
Jared
Reply