Text Box with Export Values from Multiple Selections from a Dropdown Box with '\n' after each entry
Hi everyone.
First off, I am referring the original post...
Trying To Populate a Text Box with Export Values from Multiple Selections from a Dropdown List Box
The document level function is being used here....
function fillRoles(doc, fieldName, newValue)
{
var ar = [];
// Get the value(s) currently stored in the dropdown value and
// convert them to an array
var v = doc.getField(fieldName).value;
if (v.length > 0) {
var ar = v.split(",");
}
// Do we already have newValue in the array?
var foundIt = -1;
for (var i=0; i<ar.length; i++) {
if (ar[i] == newValue) {
foundIt = i;
break;
}
}
if (foundIt != -1) {
// remove the item
ar.splice(i, 1);
}
else { // add the item at the end
ar.push(newValue);
}
// convert the array to a string
this.getField(fieldName).value = ar.join();
}
Custom Keystroke script on the Dropdown-
if(!event.willCommit) fillRoles(this, "textbox name here", event.changeEx);The code works fine with "," separated export value entry from dropdown list to the text field. Also work fine with the splice () function to remove the export value from the text field when the item is 2nd time clicked.
I have inserted a new line '\n' for each export value to be inserted with new line.
this.getField(fieldName).value = ar.join('\n');
This creates a new line in each entry in the text field. But when i 2nd time click the same item from the dropdown list it does not remove the export value from the text field.
So this is what I am trying to achieve.
Is this possible? If so, does anyone have any idea of how to do something like this?
Thank you.
