A customer had the need for a field on their company screen that works superficially like the highlighted section in this picture of the new communication screen.
Really what the customer wanted was to have a field that contains a list of user names. The user names need to get added to the list by the user picking them from a user selection box so that they don’t have to remember the names.
This can be done by creating two fields, one as a user select and another as a text box.
Let's say these fields are
comp_demo (user select)
comp_usercollection (multiline text box)
We can use the onchange event of the user select field to put its value into the text box. The onchange would first get the value of what was in this box and then concatenate the new selection to the end.
Now a user selection box only returns the UserID not the name, so how can we use that to build a list of names?
In this case it is only the names of the users that the customer wants. Because of this we can certainly use the two fields approach as although the select list value is the userid, nonetheless the prompt associated with the option contains the name. We can then have that written into the multiline text box.
Select lists like the user list are made up of Options.
The clientside Option object in JScript has two relevant properties. The 'value' and the 'text'.
The 'value' contains, well, the Value
The 'text' contains the prompt.
Also with selection lists you may have to faff around with the options[] and selectIndex properties of the 'select' to get the right thing. The following code can then be used in the user select field
var intOption = document.EntryForm.comp_demo.selectedIndex;
var strPrompt = document.EntryForm.comp_demo.options[intOption].text + ', ';
//alert(intOption);
//alert(strPrompt);
document.EntryForm.comp_usercollection.value += strPrompt;