Listbox processing

Results 1 to 2 of 2

Thread: Listbox processing

  1. #1
    Paul Winfield Guest

    Default Listbox processing

    I have a form with a textbox and a select box (used in a listbox format). What I want to do is give the user the facility to add items from the textbox to the select box, and also remove them. I assume this should be possible but I can&#039t figure out how to add text to my listbox.<BR><BR>I&#039m probably just missing the obvious, but any pointers would be appreciated!<BR>

  2. #2
    sigma Guest

    Default RE: Listbox processing

    To add an item to a select box(list1) from a textbox(text1) use the following code<BR><BR>var el=document.createElement("option")<BR>el.value=te xt1.value<BR>el.text=text1.value<BR>list1.add(el)< BR><BR>To remove an item from a listbox you can use the following code<BR>list1.remove(index)<BR>where index is the index of the option you want to remove. So to remove the currently selected item you should be able to do<BR>list1.remove(list1.selectedIndex)<BR>

Posting Permissions

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