473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Select multiple items from a dropdown

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
2 9601
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
1
by: JIM.H. | last post by:
Hello, I usee this to find string sD in drop down list and select the value. dllSP.SelectedIndex = dllSP.Items.IndexOf(dllSP.Items.FindByText(sD); Can I get FindByText work with wildcards? So...
4
by: =?Utf-8?B?c2lMdmVy?= | last post by:
Hhi, I'm working on an asp .net project that have small side panel which 'disallow' long SELECT/dropdown list.. So i could not force them to a certain that shows my longest option, which now...
3
by: laredotornado | last post by:
Hi, What is a cross-browser way to get the size (number of visible items) of a SELECT element? If that is not possible, how would I determine if the element was of a MULTIPLE type or not? ...
2
by: trint | last post by:
In my winform, I have 3 dropdown style comboboxes. I want the program to always start with the "Todays date" to be selected in the three comboboxes. example of todays date selected by using all...
0
by: cmrhema | last post by:
Hi, I have two controls one html select control and one asp.net dropdownlist control. In html select control i have three maps loaded. It is loaded in the following manner. <SELECT...
4
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I have an ASP .NET page with codebehind in a vb file. The page has a dropdown control, and a JS function which used HTTP XML Request to get the data from the database, and populate the...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.