Thanks for the post Adam, I will try this later this afternoon after my lunch. :-)
-----Original Message----- From: Adam Haskell [mailto:[EMAIL PROTECTED] Sent: 07 December 2005 12:34 To: Javascript Subject: Re: Controlling the population of drop-downs Makes good sense to me :) <script> player_list = []; player_list['001'] = ['Bob',null]; player_list['002'] = ['Roy',null]; player_list['003'] = ['Gary',null]; player_list['004'] = ['Hauns',null]; player_list['005'] = ['Chris',null]; function populateSelect(selectElement,list) { selectElement.length = 0; for(var player_id in player_list) { if(player_list[player_id][1] == null || player_list[player_id][1] == selectElement.name) { selectElement.options[selectElement.length] = new Option(player_list[player_id][0] , player_id); if(player_list[player_id][1] == selectElement.name) { selectElement.selectedIndex = selectElement.length-1; } } } } function initForm(theForm) { for(var i = 0; i < theForm.elements.length; i++) { //second part of the if is useful if you have additional select boxes //alert(theForm.elements[i].type+ ' '+theForm.elements[i].getAttribute('teamselect')) if(theForm.elements[i].type == 'select-one' && theForm.elements[i].getAttribute('teamselect') != 'undefined') { populateSelect(theForm.elements[i],player_list); theForm.elements[i].onchange = function () { changeSelectedPlayer(this); initForm(this.form); }; } } } function changeSelectedPlayer(elem) { for(var player_id in player_list) { if(player_list[player_id][1] == elem.name) { player_list[player_id][1] = null; } } player_list[elem.options[elem.selectedIndex].value][1] = elem.name; } </script> I didn't really test it for much more than valid syntax but shoul get ya an idea... Adam On 12/7/05, Andy McShane <[EMAIL PROTECTED]> wrote: > > Ian, thanks for your reply. OK, here is the scenario. The 11 drop down > boxes > each represent a playing position within a football (soccer) team. The > idea > is that the same player cannot be in more than 1 position at any one time. > So, each drop down has to have the same list of team players and when 1 is > selected in a position he can no longer be available for selection in any > other position. Does that make it clearer? > > > -----Original Message----- > From: Ian Skinner [mailto:[EMAIL PROTECTED] > Sent: 06 December 2005 19:12 > To: Javascript > Subject: RE: Controlling the population of drop-downs > > Hi all, I have a cfm page that has 11 select boxes on it. These select > boxes > will be populated with the same recordset. What I need to be able to do is > once an option has been chosen in 1 select box then all of the other > select > boxes are updated to exclude what was selected so that the same thing > cannot > be selected twice. Is it at all possible to do this without having to > resort > to a post back? Is there some javascript magic that can handle this? > > First question is, why do you have 11 drop down lists with the same record > set in it? > > To answer your question, yes JavaScript could be used to remove selected > values from other boxes, but depending on the answer to the first > question, > it may not be necessary. > > > -------------- > Ian Skinner > Web Programmer > BloodSource > www.BloodSource.org > Sacramento, CA > > "C code. C code run. Run code run. Please!" > - Cynthia Dunning > > Confidentiality Notice: This message including any > attachments is for the sole use of the intended > recipient(s) and may contain confidential and privileged > information. Any unauthorized review, use, disclosure or > distribution is prohibited. If you are not the > intended recipient, please contact the sender and > delete any copies of this message. > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:33:2086 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/33 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:33 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.33 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
