Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

Forms - Preventing Multiple Choices from a drop down menu

This is a discussion on "Forms - Preventing Multiple Choices from a drop down menu" within the Web Page Design section. This forum, and the thread "Forms - Preventing Multiple Choices from a drop down menu are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 26th, 2008, 20:02
New Member
Join Date: May 2007
Location: Nottingham, England
Age: 20
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Forms - Preventing Multiple Choices from a drop down menu

Hey everybody hope you're well.

What I have in my form is 9 drop down menus with 24 options in each menu.

Each of the drop down menus have the same 24 choices but I need to stop people choosing the same option twice or more.

Here is my code...

Code: Select all
<form action="http://www.formlog.com/cgi-bin/formuk.cgi" onsubmit="return validate_form(this)" method="POST">
<input type="hidden" name="username" value="piratescotty"> 
    <table border="10" cellpadding="2" cellspacing="1" bordercolor="0000FF" bordercolorlight="6666FF" 

bordercolordark="0000CC">
      <tr> 
        <td><div align="right"><font face="Arial" color="white">Username</font></div></td>
        <td><input type="text" name="name" rows="1" cols="20"></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">&nbsp;</font></div></td>
        <td>&nbsp;</td>

      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">1st</font></div></td>
        <td> <SELECT name="1st">
                        <OPTION value="Accrington" selected>Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">2nd</font></div></td>

        <td> <SELECT name="2nd">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot" selected>Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">3rd</font></div></td>
        <td> <SELECT name="3rd">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet" selected>Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>

      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">4th</font></div></td>
        <td> <SELECT name="4th">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford" selected>Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">5th</font></div></td>

        <td> <SELECT name="5th">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford" selected>Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">6th</font></div></td>
        <td> <SELECT name="6th">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury" selected>Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>

      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">7th</font></div></td>
        <td> <SELECT name="7th">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester" selected>Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">&nbsp;</font></div></td>
        <td>&nbsp;</td>

      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">23rd</font></div></td>
        <td> <SELECT name="23rd">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury" selected>Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe">Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td><div align="right"><font face="Arial" color="white">24th</font></div></td>

        <td> <SELECT name="24th">
                        <OPTION value="Accrington">Accrington Stanley</OPTION>
                        <OPTION value="Aldershot">Aldershot Town</OPTION>
                        <OPTION value="Barnet">Barnet</OPTION>
                        <OPTION value="Bournemouth">Bournemouth</OPTION>
                        <OPTION value="Bradford">Bradford City</OPTION>
                        <OPTION value="Brentford">Brentford</OPTION>
                        <OPTION value="Bury">Bury</OPTION>
                        <OPTION value="Chester">Chester City</OPTION>
                        <OPTION value="Chesterfield">Chesterfield</OPTION>
                        <OPTION value="Dagenham">Dagenham & Redbridge</OPTION>
                        <OPTION value="Darlington">Darlington</OPTION>
                        <OPTION value="Exeter">Exeter City</OPTION>
                        <OPTION value="Gillingham">Gillingham</OPTION>
                        <OPTION value="Grimsby">Grimsby Town</OPTION>
                        <OPTION value="Lincoln">Lincoln City</OPTION>
                        <OPTION value="Luton">Luton Town</OPTION>
                        <OPTION value="Macclesfield">Macclesfield Town</OPTION>
                        <OPTION value="Morecambe">Morecambe</OPTION>
                        <OPTION value="Notts County">Notts County</OPTION>
                        <OPTION value="Port Vale">Port Vale</OPTION>
                        <OPTION value="Rochdale">Rochdale</OPTION>
                        <OPTION value="Rotherham">Rotherham United</OPTION>
                        <OPTION value="Shrewsbury">Shrewsbury Town</OPTION>
                        <OPTION value="Wycombe" selected>Wycombe Wanderers</OPTION>
                      </SELECT></td>
      </tr>
      <tr> 
        <td height="27"> <div align="right"> 
            <input name="submit" type="submit" value="Submit">
          </div></td>
        <td><input name="reset" type="reset" value="Reset"></td>
      </tr>

    </table>


    </form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Jul 27th, 2008, 11:35
Reputable Member
Join Date: Jul 2008
Location: UK and Spain
Age: 24
Posts: 104
Thanks: 2
Thanked 14 Times in 13 Posts
Re: Forms - Preventing Multiple Choices from a drop down menu

In your validation script (validate_form) that you call when the form is submitted, you just need to put a call to check each of the select boxes.

Also, it would be best not to start your select box names with a number, so if you call them "first", "second", "third"... etc then you could use the following javascript:
Code: Select all
function validate_form() {
  var value1 = document.formname.first.value;
  var value2 = document.formname.second.value;
  if(value1==value2){
      alert('your error message here!');
      return false;
  }
}
That will pop up a box alerting the user, and will stop the form from submitting.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple drop-down menus ktsirig JavaScript Forum 2 May 28th, 2008 23:54
Multiple drop down menus D4CUE Web Page Design 3 Mar 6th, 2008 09:06
Multiple forms on Opera QuikFrozen Web Page Design 3 Nov 7th, 2006 16:19
Multiple Drop Down stevoh PHP Forum 2 Nov 25th, 2005 18:52
Multiple Drop Down Validation Monie JavaScript Forum 1 Nov 6th, 2004 08:41


All times are GMT. The time now is 19:19.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8