Unselecting a Selection?

Question: I am using javascript to dynamically create a select list when the page loads. The list options are populated from values stored in a cookie. The user can select (highlight) one option at a time in this list. How can I allow the user to clear the selection in this list (un-highlight it) when a click performs the highlight action? Code such as "var i = thisform.myList.selectedIndex; thisform.myList[i].selected = false;" does not seem to work. Thanks
Susan Keenan

Answer: As far as I know, the only way to clear a selected entry in a drop down list is to select another entry within the list as one entry within the list must always be selected. Where a list is created and a selected entry is not specified then the first entry will be selected by default (even if it is not highlighted). The only way I can think of to provide the functionality that you want is to provide a blank entry in the list that can has no associated action (or which displays an alert telling your visitor to select one of the other options) and select that one when the function associated with any of the other options is complete.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow