Adding Item to Combo Box with JavaScript

I have a form that is accessible via the web and would like to allow the Topic combo box to display preset topics as well as allow the user to enter a new topic.

I have searched the forum for allowing item not in list and found this reply:

It’s because you check “Allow values not in list” in the field properties. Domino has to choose from among the field types available in HTML, and there is no HTML field type which lets you choose from a list and enter any value you want.

For the web, you have to do a little work to get that same functionality. Make it a regular combobox field, and add a JavaScript control to prompt them for a new value and add it to the list of choices. (Andre Guirard)

Has anyone gotten something like this to work? If so, could you point me in the right direction - not sure about the JavaScript. Any ideas or suggestions would be greatly appreciated. Thanks in advance.

Subject: Adding Item to Combo Box with JavaScript

You can easily add a button to the right of the combo to prompt for a new value. It will then appends this value to the combo-list.

Include the javascript function in you notes form (JS Header).

On your note form insert a line just after your list, hide it for reading and Notes, and set it to “pass-thru HTML”. Then insert the code for the button.

Example : (you can save the following code to see how it works in a brower).

Eric.


Subject: Adding Item to Combo Box with JavaScript

  • I wound up using three fields for this.1. Regular Notes field with allow values not in the list. It displays only in Notes. (grin)
  1. Regular Notes list (without allow values) that shows the user their selections for the web.

  2. Regular Notes text field (no list at all) just below the web list that allows the users to enter new values on the web.

  • With the correct Form logic, the web field value is put into the normal Notes field, and the web fields are deleted, so any back-end code only sees the Notes value. If a document is opened on the Web, the web list field is populated for that document load only, so on save it’s put into the Notes field and deleted again.

  • For the web, the text field has priority, since you can’t easily prevent the user from populating both the list and text field. This is for the logic that puts the web data into the Notes field. If there’s a value in the web text field, ignore the list, otherwise save it, essentially.

  • Both lists (notes and web) drive from the same keyword formula, based on document contents, so they stay in sync even as new values are added on the Web, or in Notes.

  • This sounds more complex than it really is. We’ve had this in production for about a year now, on an application that works in either client. If you don’t need the Notes client, you could keep the web list field and have the text field merge into it instead of the Notes field.

  • Hope this helps…