Help with HTML forms and Select lists?
I have two select lists, each with identical options A, B, and C. I want the user to choose an option from the first list, and then an option from the second list THAT IS NOT THE SAME AS THE FIRST. I could do this either dynamically, by displaying only the first list, and then after a selection is made, display the second list minus the choice that was made from the first. I could also display both lists at once and compare the choices, and then give an alert if they match. I am still new to HTML/Javascript so I don't really know how to code this. Any help?
Public Comments
- ... <select id="list-a" onchange="checkLists"> ... <script type="text/javascript"> function checkLists() { var listA = document.getElementById('list-a'); var listB = document.getElementById('list-b'); if(listA.selectedIndex == listB.selectedIndex) { alert('Lists have the same options selected'); } }
- I suggest you use a <select> element with the multiple attribute set to true. This will allow the user to select multiple options from the same list. To limit the selection to a max of two, you need to listen to the onchange event then programmatically de-select the first choice found in the list if three are found.
Powered by Yahoo! Answers