473,395 Members | 1,641 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,395 software developers and data experts.

Remove Selected Item from list

I have an issue that I am trying to solve. I have three select lists
(supposed to be preference 1, 2,3) and each of them have the same three
options. As soon as I select one of the choices from list1, i would
like to remove it from the options of list 2 and so on for list 3.

So effectively, List 2 has two choices and List3 only has one choice
that can be made.

Any pointers on how to accomplish this?

Oct 19 '05 #1
8 2275
VK
<http://www.google.com/search?hl=en&q=select+list+remove+option+JavaScrip t>

Oct 19 '05 #2
Unfortunately, I really havent been able to get this going at all. I
havent found much help to proceed any further. Any pointers, please?

Oct 25 '05 #3
<rk******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have an issue that I am trying to solve. I have three select lists
(supposed to be preference 1, 2,3) and each of them have the same three
options. As soon as I select one of the choices from list1, i would
like to remove it from the options of list 2 and so on for list 3.

So effectively, List 2 has two choices and List3 only has one choice
that can be made.

Any pointers on how to accomplish this?


Is this what you're looking for? Watch for word-wrap.

<html>
<head>
<title>3selects.htm</title>
<script type="text/javascript">
function selects(n) {
var form = document.form1;
var indx = document.getElementById("s"+n).selectedIndex;
var valu = document.getElementById("s"+n).options[indx].value;
for (i=1; i<4; i++) {
if (i != n) {
for (j=0; j<document.getElementById("s"+i).length; j++) {
var what = document.getElementById("s"+i).options[j].value;
if (valu == what) {
document.getElementById("s"+i).options[j] = null;
}
}
}
}
}
</script>
</head>
<body>
<form action="" method="get" name="form1">
<select name="s1" id="s1" onchange="selects(1)" size="3">
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>
<select name="s2" id="s2" onchange="selects(2)" size="3">
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>
<select name="s3" id="s3" onchange="selects(3)" size="3">
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>
</form>
</body>
</html>

If your task is to rank the preferences of three options then you might
want to consider just having two selections lists; one with the three
options and the other blank. As an option is selected it is added to
the second list in the order it was selected (and removed from the first
list). Then you process the second list for all values.

Oct 25 '05 #4
Thnaks a ton. That was precisely what I was looking for...... infact, I
was looking for soem pointers, but you provided the solution. Is there
a way to star a solution?

Thanks McKirahan

Oct 27 '05 #5
"Meister" <rk******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thnaks a ton. That was precisely what I was looking for...... infact, I
was looking for soem pointers, but you provided the solution. Is there
a way to star a solution?

Thanks McKirahan


What do you mean by: "Is there a way to star a solution?"?

Are asking about the "two selections lists" approach?
Oct 28 '05 #6
In article <Dv********************@comcast.com>,
"McKirahan" <Ne**@McKirahan.com> wrote:
"Meister" <rk******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thnaks a ton. That was precisely what I was looking for...... infact, I
was looking for soem pointers, but you provided the solution. Is there
a way to star a solution?

Thanks McKirahan


What do you mean by: "Is there a way to star a solution?"?

Are asking about the "two selections lists" approach?


I'm going out on a limb here, but I think he's asking if there is a way
to highlight a solution on Usenet. The answer, of course, is no.
Oct 28 '05 #7
"Mark Twain" <tw***@whitehouse.gov> wrote in message
news:1130504996.8872205f0eb5b2e0e763e7e041bc8757@t eranews...
In article <Dv********************@comcast.com>,
"McKirahan" <Ne**@McKirahan.com> wrote:
"Meister" <rk******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thnaks a ton. That was precisely what I was looking for...... infact, I was looking for soem pointers, but you provided the solution. Is there
a way to star a solution?

Thanks McKirahan


What do you mean by: "Is there a way to star a solution?"?

Are asking about the "two selections lists" approach?


I'm going out on a limb here, but I think he's asking if there is a way
to highlight a solution on Usenet. The answer, of course, is no.


I thought that might be what's meant but here's the other approach....
<html>
<head>
<title>3rank.htm</title>
<script type="text/javascript">
var opti;
function rank(what) {
var form = document.form1;
if (what == 0) {
form.s1.options[0] = new Option("One", 1);
form.s1.options[1] = new Option("Two", 2);
form.s1.options[2] = new Option("Three", 3);
form.s2.options[2] = null;
form.s2.options[1] = null;
form.s2.options[0] = null;
opti = 0;
} else {
var indx = form.s1.selectedIndex;
if (indx < 0) return;
var text = form.s1.options[indx].text;
var valu = form.s1.options[indx].value;
form.s1.options[indx] = null;
form.s2.options[opti++] = new Option(text, valu);
}
}
</script>
<style type="text/css">
..sel1 { width:80px }
..sel2 { width:80px; background:#EFEFEF }
</style>
</head>
<body onload="rank(0)">
<form action="" method="get" name="form1">
<select name="s1" id="s1" size="3" class="sel1" onclick="rank(1)">
</select>
<select name="s2" id="s2" size="3" class="sel2" disabled>
</select>
<input type="button" value="Reset" onclick="rank(0)">
</form>
</body>
</html>
Oct 28 '05 #8
yeah i was looking to mark an answer as a solution

Nov 23 '05 #9

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

Similar topics

4
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the...
1
by: Hrvoje Voda | last post by:
How to remove selected item from listBox? Hrcko
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
4
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The...
3
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
2
by: Hitesh | last post by:
I have a listbox and the values get selected (highlighted) from code. I can highlight the corresponding list box items, but they do not show in the listbox I have to scroll through the list box to...
3
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
1
by: bairamsunil | last post by:
I have a list box in which items are selected alternately, depending on the selection I have to remove the records in another table which matches this item as well as i have to refresh the list box....
2
by: Vagos | last post by:
Hello, I am using list boxs, my NewLoan button works just fine, adds the loans to the specific lstLoans area, but this code won't delete the selected item, any suggestions? Here is the code : ...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.