473,695 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9618
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.c om> wrote in message
news:eE******** ******@TK2MSFTN GP10.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
4291
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. Based on the number of variables passed through a GET string, I want to multiply the total number of selected items for each together to see how many possible combinations the selected items are generating. The following snippet of code...
7
4214
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 the first item in the dropdown is always displayed. Template Code: <asp:TemplateColumn HeaderText="DropDown"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval
1
2158
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 dropdown list has xyzt, and if sD is xyz, I need to select xyzt. Right now it does not select since is expects whole match. How can I do this? Thanks, Jim.
4
5802
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 most of my option was being 'cut-off' half way, not able to show to full text.. Is there any way I could do some thing like in e Mozilla FireFox (as currently using IE), which 'opens' e dropdown list when being click and shows e full text that...
3
12362
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? Thanks, - Dave
2
3072
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 three combo dropdown boxes: cboDropDownStyle1 = June | cboDropDownStyle2 = 26 | cboDropDownStyle3 = 2007 Those items already exist in the comboboxes, I just want them
0
1517
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 class="TextBoxLabel" id="ddlMap" style="WIDTH: 128px;" tabIndex="1" onchange="fnChangeMap();" name="ddlMap" runat="server">
4
1590
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 dropdown. Actually, the JS creates the OPTION elements using th retrieved db data, and adds them to the SELECT element using DOM objects. The dropdown works ok, and the items are visible, but when the user clicks "Save" button, and the page posts...
25
5390
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. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
0
8631
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7661
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6491
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2272
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.