473,385 Members | 1,757 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.

How to keep selected values in select field?!?

I want to keep selected values in select list when i click on another
option...with a click on a mouse...

if i have 3 options in select list and i click first option..it gets
selected..if i then click on third option ..it gets selected but i want
also the first option to stay selected

when i click on option that is already selected, then it should be
deselected

if i double click on option...than only this option should be selected

so........

I tried to use onChange and onClick events on select field..the problem
is that in onChange event i get selectedIndex that represents and
option that i have just clicked (i can't get previously selected
options)..

in onClick event i cannot even get the options i just selected, just
previously selected..

so i was thinking to combine this two events to get all selection,
previosly selected and option taht i selected last

the proble is that when i fill array with an options that was previosly
selected and i want to use this array in onClick event, the array is
undefined...

so heres my problem...if anyone knows how to solve it or just give me
some advice , i'll be very happy :)

thx and bye

Oct 11 '05 #1
1 2743
sm*******@gmail.com wrote:
I want to keep selected values in select list when i click on another
option...with a click on a mouse...

if i have 3 options in select list and i click first option..it gets
selected..if i then click on third option ..it gets selected but i want
also the first option to stay selected

when i click on option that is already selected, then it should be
deselected

if i double click on option...than only this option should be selected

so........

I tried to use onChange and onClick events on select field..the problem
is that in onChange event i get selectedIndex that represents and
option that i have just clicked (i can't get previously selected
options)..

in onClick event i cannot even get the options i just selected, just
previously selected..

so i was thinking to combine this two events to get all selection,
previosly selected and option taht i selected last

the proble is that when i fill array with an options that was previosly
selected and i want to use this array in onClick event, the array is
undefined...

so heres my problem...if anyone knows how to solve it or just give me
some advice , i'll be very happy :)

thx and bye

Hi,

Use the keyword multiple in your select

<select name="food" multiple>
<option value="1">banana
<option value="2">apple
<option value="3">pear
</select>

If you want to find out which options are selected at a certain moment, do
not use selectedIndex, it only works good for single-option slectbox.
In that case just loop over all option and check the 'selected' property by
hand.

Hope that helps.

Good luck!
Regards,
Erwin Moller
Oct 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Lisa | last post by:
I have a drop down that defaults to "select" after the page refreshes. How do I keep the selected value in the dropdown field... I've tried EVERYTHING and nothing works! :( <script...
3
by: Sarah West | last post by:
Hi, I have the following problem; This is my form, i would like to default the select box to USA, and default the text field to a name such as 'Sarah' and the hidden field to another number...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
5
by: Elvis V. | last post by:
Good morning, I have a table with three fields, Buildings, Floors and Rooms. This is what I would like to do; in my form when I select Building1 in my drop down box for Buildings, when I go to the...
0
by: Elvis V. | last post by:
Good morning, I have a table that contains three fields that I would like to relate one to another, in other words, for example, when I go to the form and I click on the drop down box for...
0
by: Mike | last post by:
My original problem was solved by Bruce Dodds (Thanks!!) ORIGINAL PROBLEM I have developed an application for data enty for daily production in my factory. I have one combo box for shifts...
4
by: Dave Brydon | last post by:
Access 2003 I have a combo box in my personnel table, which draws its data from a trade code table; the original field in the code table, is numeric, Long Integer, and formatted with 5 zero's . ...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
1
by: julianomartins | last post by:
Hi friends, how I make to recoup the value of database and to keep selected in combobox to edit my form? in script below it is selected field of the table that possesss id of the first item of...
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: 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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.