View Full Version : Deselect selected Items in Listbox

06-09-2004, 05:33 PM

I am using drop down menus, text field and listbox as search fields in my search program. I have a jsp which populates the listbox and drop downs. I use Java script to check whether an item seleced is in listbox or dropdown and perform the search and display the result using JSP.

When I select an item in the list box and click "search", I get the result. But, if I want to deselect it, I cudnt do it. And another thing, if I select multiple items, i can deselect everything but one. I cudnt deselect everything in the listbox once I make a selection. I am using a multiple select listbox. Please anyone lemme know how to deselect.

Thanks in advance,

Mr J
06-09-2004, 06:43 PM
I think you need to add something like this

formName.optionName.options[indexNumber] = null;

06-09-2004, 06:48 PM
this might also work:

<input type="button" onclick="this.form.selectbox.selected=null"/>

06-10-2004, 05:44 AM
Should be:

<input type="button" onclick="this.form.theSelect.selectedIndex=-1"/>