Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deselect selected Items in Listbox

    Hi,

    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,
    Priya

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    I think you need to add something like this


    formName.optionName.options[indexNumber] = null;

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this might also work:

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

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Should be:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •