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
|