469,612 Members | 2,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

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 2093
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by anonymous | last post: by
2 posts views Thread by Fraggle_Rock_1 | last post: by
4 posts views Thread by Paul | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.