By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Select multiple items from a dropdown

P: n/a
Jas
I want an ASP page with a dropdown and a simple button. Every time the user
chooses an item from the dropdown and clicks on the button i want that value
written below in list and allow user to select more.

Also how can these choices be saved somehow so tha when the user goes to the
next page the choices he made can be written to the database.

For example

The choices in the dropdown may be

London
Dublin
Paris
New York

When the user chooses Dublin I want ti written below the dropdown. Then when
he chooses New York. I want it added to london. so that it displays

Dublin
London

Then when he click next button these two choices are taken over to the next
page where an insert query can be used to insert them into the db.


Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Well, one thing you could do is use a mulit-line select with the multiple
option that will let the users select multiple options. But, that is not
what you described. So, what you can do is post the page back to itself and
write the value of the selected item to a hidden input on the bottom of the
page. Then when the user selects another one and submits, add that
selection to the input as well. Keep doing that, and then when the user
selects the other submit button, the one that signifies he's finished, grab
the value of the select and the hidden input(s) for all the values.

Ray at work

"Jas" <ja*@jjskkssk.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl...
I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that value written below in list and allow user to select more.

Also how can these choices be saved somehow so tha when the user goes to the next page the choices he made can be written to the database.

For example

The choices in the dropdown may be

London
Dublin
Paris
New York

When the user chooses Dublin I want ti written below the dropdown. Then when he chooses New York. I want it added to london. so that it displays

Dublin
London

Then when he click next button these two choices are taken over to the next page where an insert query can be used to insert them into the db.

Jul 19 '05 #2

P: n/a
Actually, I have implemented that exact scenario on one or
two of my pages.

Basically I have two select boxes with some size greater
than one (so that it will display more than one line).
Then I use javascript to copy the selected value from the
first select box to the second.
Then, when the page is submitted, I read the values in the
2nd select box and populate an array with that data using
javascript.
Next, again using javascript, I copy the contents of the
array to a hidden text field on the form.
Finally, I submit the form, again using javascript.

I know this sounds complicated, but there are no reposts,
or roundtrips to the server except for the final posting
of the form. The entries get added to the 2nd select box
immediately and they all get processed at one time when
the page gets submitted. I also have code to delete any
entry from the 2nd select box using roughly the same
process (in reverse).

Note: the reason for populating the array and not the
hidden text field directly is so that I can sort the
entries before processing the page - makes it a little
easier to check for duplicate entries when updateing the
SQL database. If you don't need to sort, you could
populate the text field directly from the select box.

HTH,
John
-----Original Message-----
I want an ASP page with a dropdown and a simple button. Every time the userchooses an item from the dropdown and clicks on the button i want that valuewritten below in list and allow user to select more.

Also how can these choices be saved somehow so tha when the user goes to thenext page the choices he made can be written to the database.
For example

The choices in the dropdown may be

London
Dublin
Paris
New York

When the user chooses Dublin I want ti written below the dropdown. Then whenhe chooses New York. I want it added to london. so that it displays
Dublin
London

Then when he click next button these two choices are taken over to the nextpage where an insert query can be used to insert them into the db.

.

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.