Checking if a string contains "text" from a box, and only if it doesn't, add it to the string.
I have a few comboboxes. I want a text field to add a string to itself, containing the text selected from each combobox. I got it, using this:
var a = this.getField("CoBi_text");
for (i=1;i<16;i++) {
var t = (this.getField("CoB_"+i).valueAsString);
if (t != ""){
a.value += t+", "; } }
But this adds the same text if I select the same option in any combobox. How do I include a conditional do skip the increment if "text is already in the string? I tried this:
if ( (t != "") && (a.value.indexOf("t")<0) ) {
a.value += t+", "; }
But it causes the string to add only the first text, not incrementing any more text after that.
PS. this text field will be hidden and later used on another condition (if it contains "specific text"), some other actions trigger.
So the ", " (comma) is probably not necessary, but I think it shouldn't be in the way of a proper indexOf search (right?)
Thanks.