473,387 Members | 3,821 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,387 software developers and data experts.

Evaluate Options in Dropdown for Unique Selection?

JL
Does anyone have any ideas on this please?

I don't know how to evaluate the no-blank selections against each other from
a form as follows: .

I have a form with 6 dropdown fields, each containing a selection of 30
options (the 30 options are the same for each dropdown list).
The user needs to select 'one of the 30 options' from each dropdown
selection, but each option they select must be unique (no duplicate
selections) or it must be left blank.
E.g. The user can select Option3 within "dropdown1", but must select a
different option for the other dropdowns - OR leave them unselected.

Any help is greatly appreciated...

JL
Jul 23 '05 #1
10 2270
In article <wv***************@newsfe1-gui.server.ntli.net>,
de***********@THISBIThotmail.com enlightened us with...
E.g. The user can select Option3 within "dropdown1", but must select a
different option for the other dropdowns - OR leave them unselected.

Any help is greatly appreciated...

JL


I don't suppose they're all in the same order so that the selectedIndex
would be the same if the option were the same?

--
--
~kaeli~
When you choke a smurf, what color does it turn?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
JL
The dropdown options would be dynamically populated from a database list (so
would be in the same order for the 6 dropdown menus).

The option labels would be the "candidate names" and the option value would
be the "candidate Ids". When submitted, these would be inserted in to a
database table along with the user's details (as a voting system).

Could this be done having the list like this?
"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
| In article <wv***************@newsfe1-gui.server.ntli.net>,
| de***********@THISBIThotmail.com enlightened us with...
| > E.g. The user can select Option3 within "dropdown1", but must select a
| > different option for the other dropdowns - OR leave them unselected.
| >
| > Any help is greatly appreciated...
| >
| > JL
| >
| >
| >
|
| I don't suppose they're all in the same order so that the selectedIndex
| would be the same if the option were the same?
|
| --
| --
| ~kaeli~
| When you choke a smurf, what color does it turn?
| http://www.ipwebdesign.net/wildAtHeart
| http://www.ipwebdesign.net/kaelisSpace
|
Jul 23 '05 #3
"JL" <de***********@THISBIThotmail.com> skrev i meddelandet
news:wv***************@newsfe1-gui.server.ntli.net...
Does anyone have any ideas on this please?

I don't know how to evaluate the no-blank selections against each other from a form as follows: .

I have a form with 6 dropdown fields, each containing a selection of 30
options (the 30 options are the same for each dropdown list).
The user needs to select 'one of the 30 options' from each dropdown
selection, but each option they select must be unique (no duplicate
selections) or it must be left blank.
E.g. The user can select Option3 within "dropdown1", but must select a
different option for the other dropdowns - OR leave them unselected.

Any help is greatly appreciated...

JL


How about regenerating the dropdowns as new selections are made?
You have a base set of 30 options, then:
* Fill first dropdown with all options
* Fill second dropdown with all options except the one selected in the first
dropdown
* Fill third dropdown with all options except what's selected in first and
second dropdowns, etc.

When a selection is made, you regenerate all dropdowns "downstream" from the
one modified.

Might be a bit slow, but at least the user can't select a nonexistent item.

Joakim Braun

Jul 23 '05 #4
In article <Ja**************@newsfe1-gui.server.ntli.net>,
de***********@THISBIThotmail.com enlightened us with...
The dropdown options would be dynamically populated from a database list (so
would be in the same order for the 6 dropdown menus).

The option labels would be the "candidate names" and the option value would
be the "candidate Ids". When submitted, these would be inserted in to a
database table along with the user's details (as a voting system).

Could this be done having the list like this?


It could be done no matter how the list was built, it's just a lot
easier if the selectedIndex is the same for equal fields.

I made a little example with 3 selects with 6 options each. Tested in
IE6. Checks only for duplicates. If you want to make sure there is a
selection, make sure the first element is a "Select one" type, then
check for a[i] being equal to 0 as well as being equal to the next a[i+
1].

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function verify(frm)
{
var a = new Array(frm.select_1.selectedIndex,frm.select_
2.selectedIndex,frm.select_3.selectedIndex);
a.sort();
for(i=0; i<a.length; i++)
{
if(a[i]==a[i+1])
{
alert("error: duplicates");
return false;
}
}
return true;
}
</script>
</head>

<body>
<form name="f1" onSubmit="return verify(this)">
<select name="select_1">
<option value='0'>zero</option>
<option value='1'>one</option>
<option value='2'>two</option>
<option value='3'>three</option>
<option value='4'>four</option>
<option value='5'>five</option>
</select>
<br>
<select name="select_2">
<option value='0'>zero</option>
<option value='1'>one</option>
<option value='2'>two</option>
<option value='3'>three</option>
<option value='4'>four</option>
<option value='5'>five</option>
</select>
<br>
<select name="select_3">
<option value='0'>zero</option>
<option value='1'>one</option>
<option value='2'>two</option>
<option value='3'>three</option>
<option value='4'>four</option>
<option value='5'>five</option>
</select>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

--
--
~kaeli~
Never say, "Oops!"; always say, "Ah, interesting!"
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #5
JL
Hi Kaeli,

I couldn't get the page to work (nothing happened when I made the same
selections and pressed submit) - was there something else I needed to do to
get it to work?

Thanks
JL
| It could be done no matter how the list was built, it's just a lot
| easier if the selectedIndex is the same for equal fields.
|
| I made a little example with 3 selects with 6 options each. Tested in
| IE6. Checks only for duplicates. If you want to make sure there is a
| selection, make sure the first element is a "Select one" type, then
| check for a[i] being equal to 0 as well as being equal to the next a[i+
| 1].
|
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
| "http://www.w3.org/TR/REC-html40/loose.dtd">
| <html>
| <head>
| <title> New Document </title>
| <script type="text/javascript">
| function verify(frm)
| {
| var a = new Array(frm.select_1.selectedIndex,frm.select_
| 2.selectedIndex,frm.select_3.selectedIndex);
| a.sort();
| for(i=0; i<a.length; i++)
| {
| if(a[i]==a[i+1])
| {
| alert("error: duplicates");
| return false;
| }
| }
| return true;
| }
| </script>
| </head>
|
| <body>
| <form name="f1" onSubmit="return verify(this)">
| <select name="select_1">
| <option value='0'>zero</option>
| <option value='1'>one</option>
| <option value='2'>two</option>
| <option value='3'>three</option>
| <option value='4'>four</option>
| <option value='5'>five</option>
| </select>
| <br>
| <select name="select_2">
| <option value='0'>zero</option>
| <option value='1'>one</option>
| <option value='2'>two</option>
| <option value='3'>three</option>
| <option value='4'>four</option>
| <option value='5'>five</option>
| </select>
| <br>
| <select name="select_3">
| <option value='0'>zero</option>
| <option value='1'>one</option>
| <option value='2'>two</option>
| <option value='3'>three</option>
| <option value='4'>four</option>
| <option value='5'>five</option>
| </select>
| <br>
| <input type="submit" value="Submit">
| </form>
| </body>
| </html>
|
| --
| --
| ~kaeli~
| Never say, "Oops!"; always say, "Ah, interesting!"
| http://www.ipwebdesign.net/wildAtHeart
| http://www.ipwebdesign.net/kaelisSpace
|
Jul 23 '05 #6
JL
Hi Joakim,

Yes - this would be the ideal solution (regenerating the dropdowns as new
selections are made) but how would I do this?
Can it be done using ASP at all (rather than client side JavaScript)?
Anyone know?

Thanks
JL
| How about regenerating the dropdowns as new selections are made?
| You have a base set of 30 options, then:
| * Fill first dropdown with all options
| * Fill second dropdown with all options except the one selected in the
first
| dropdown
| * Fill third dropdown with all options except what's selected in first and
| second dropdowns, etc.
|
| When a selection is made, you regenerate all dropdowns "downstream" from
the
| one modified.
|
| Might be a bit slow, but at least the user can't select a nonexistent
item.
|
| Joakim Braun
Jul 23 '05 #7
On Wed, 21 Apr 2004 23:04:17 +0100, JL <de***********@THISBIThotmail.com>
wrote:
Yes - this would be the ideal solution (regenerating the dropdowns as new
selections are made) but how would I do this?
A question, first: do the various SELECT elements have meaning? You said
that this is for a voting system, so does a candidate in an earlier SELECT
element have preference over a candidate in a lower element? If so, this
suggestion wouldn't be a good idea as the user might have trouble changing
the order of candidates.
Can it be done using ASP at all (rather than client side JavaScript)?
Anyone know?


You could submit the page and rewrite it with each selection, but this
isn't the same effect. Unless order is irrelevant, Kaeli's suggestion is
the best client-side validation technique.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #8
JL
Hi,

The form is intended to just pick 6 candidates from the 30 available - all
six that are selected are of the same hierarchy (it doesn't matter which
order they are picked in).

Has anyone seen any scripts/applications anywhere for this type of voting
system?

Thanks all.....

JL
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk...
| On Wed, 21 Apr 2004 23:04:17 +0100, JL <de***********@THISBIThotmail.com>
| wrote:
|
| > Yes - this would be the ideal solution (regenerating the dropdowns as
new
| > selections are made) but how would I do this?
|
| A question, first: do the various SELECT elements have meaning? You said
| that this is for a voting system, so does a candidate in an earlier SELECT
| element have preference over a candidate in a lower element? If so, this
| suggestion wouldn't be a good idea as the user might have trouble changing
| the order of candidates.
|
| > Can it be done using ASP at all (rather than client side JavaScript)?
| > Anyone know?
|
| You could submit the page and rewrite it with each selection, but this
| isn't the same effect. Unless order is irrelevant, Kaeli's suggestion is
| the best client-side validation technique.
|
| Mike
|
| --
| Michael Winter
| M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #9
In article <ua**************@newsfe2-gui.server.ntli.net>,
de***********@THISBIThotmail.com enlightened us with...
Hi Kaeli,

I couldn't get the page to work (nothing happened when I made the same
selections and pressed submit) - was there something else I needed to do to
get it to work?


Aside from being careful about line breaks, no.
You did join the lines after your copy/paste, right? Word-wrap can do
bad things.

Go here and see if it works.
http://www.ipwebdesign.net/test4.html

It worked in IE6 and NN7 for me.

--
--
~kaeli~
If it's tourist season, why can't we shoot them?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #10
JL
Hi Kaeli,

Yes - it works now.
It looks like this will do the trick and it's such a small code size too!

Thank you very, very much....
:-)

JL

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
| In article <ua**************@newsfe2-gui.server.ntli.net>,
| de***********@THISBIThotmail.com enlightened us with...
| > Hi Kaeli,
| >
| > I couldn't get the page to work (nothing happened when I made the same
| > selections and pressed submit) - was there something else I needed to do
to
| > get it to work?
|
| Aside from being careful about line breaks, no.
| You did join the lines after your copy/paste, right? Word-wrap can do
| bad things.
|
| Go here and see if it works.
| http://www.ipwebdesign.net/test4.html
|
| It worked in IE6 and NN7 for me.
|
| --
| --
| ~kaeli~
| If it's tourist season, why can't we shoot them?
| http://www.ipwebdesign.net/wildAtHeart
| http://www.ipwebdesign.net/kaelisSpace
|
Jul 23 '05 #11

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

Similar topics

7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
4
by: anonymous | last post by:
Hi Folks, I have a form with two Dropdown list boxes, which get loaded with data from Database. DropDownList1 gets data from Table1 and DropDownList2 gets data from Table2 Table1 has a...
0
by: Jeff | last post by:
After I bind the repeater control in the form_load event, it builds multiple lines based on the number of rows in the dataset. In the repeater control, I have a textbox and a dropdown list box. ...
2
by: Fraggle_Rock_1 | last post by:
I have a dataset like so |ID | type | Name ------------------ |1 | 1 | ham |2 | 2 | fish |1 | 2 | lard |2 | 1 | spam
4
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost,...
2
by: 23s | last post by:
I have a dropdown bound to a dataview. The binding assigns the dropdown with a SelectedIndex of 0. There is a msgbox in the SelectedIndexChanged event that displays the SelectedIndex property....
3
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in...
3
by: sewerized | last post by:
Hello all, I'm having a problem with a user preferences form I'm creating. I want to use dynamic dropdown SELECT boxes for this so my page doesn't get cluttered with 100000 links. Since I...
3
by: er1 | last post by:
Hi all, I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query...
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: 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...
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
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
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...

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.