Link to home
Start Free TrialLog in
Avatar of JonFleming
JonFleming

asked on

Javascript: user adding items to a predefined dual select box

I'm setting up a form for users to submit our papers/presentations to a database. One item is a list of authors. all papers will be authored by at least one and perhaps several of a predefined list of names (our employees). But some of them will include someone from outside our organizatIon, and I need to accommodate that possibility. So the user has to be able to add an arbitrary item to the list of authors. And ther ehave to be "Move up" and "Move down" buttons because the user isn't necessarily going to add then names in the correct order.

I've found some javascript that can do almost all that I want except for adding a name, at http://www.applicationgroup.com/tutorials/DualListBox/DualListBox_js.asp. I'm no javascript expert, but I can hack some code to support an "Add a Name" button. But I thought I'd ask to see if someone has such code lying around in the pile ...
ASKER CERTIFIED SOLUTION
Avatar of GaryRasmussen
GaryRasmussen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Updated the Add function to make sure there is actually something to add

function Add()
{      var list = document.getElementById("cboAuthors")
      var newAuthor = document.getElementById("txtNewAuthor").value
      
      if (newAuthor != "")
      {      var option = new Option(newAuthor, newAuthor)
            list.options[list.options.length] = option
      }
}
Avatar of JonFleming
JonFleming

ASKER

Ah, thank you.