Concatenate Two Strings

Hi, I have a collection with two text fields, “tag1” and “tag2”

In the code, I’d like to concatenate the two text fields into a string variable, like this:

var tagConcat = (“tag1” & “tag2”);

Except, that doesn’t work. The following does not work either:

var tagConcat = (“tag1” + “tag2”);

Anyway to combine the text of “tag1” and “tag2” in a variable called tagConcat?

Thanks!

Hi,
You can try the following:

let tagConcat = `${$w('#tag1').value} ${$w('#tag2').value}`;

Good luck!
Tal.

Thanks, Tal! Maybe I’m asking it the wrong way. What I’m trying to do:

So tag1 and tag2 are fields in a collection. In the code below, I’m trying to make it so that “#dataset1” is filtered by the “#filterInput” searching the contents of the fields tag1 or tag2.

export function filterInput_change(event) {
$w(“#dataset1”).setFilter(wixData.filter()
.contains(“tag1” || “tag2”, $w(“#filterInput”).value));
}

Let’s say filterInput = “Apples” … I’m trying to get it so that if the word “apples” is in tag1 AND/OR tag2 field, then dataset1 will be filtered to show only those entries.

I’m dying on this one. :slight_smile:

Your help is very much appreciated!

Greg

Hi, I came across a similar problem a few weeks back. Have you tried using an or() condition?

So, I think your solution would be something like this…

export function filterInput_change(event) {    $w("#dataset1").setFilter(wixData.filter()         
.contains("tag1", $w("#filterInput").value)
.or(                      
    wixData.filter() 
    .contains("tag2", $w("#filterInput").value) ));  
} 

This is the thread where I posted and got the answer!

Hi
Similar question
i would like before saving the entry
concatenate 2 numeric fields NfieldA and NfieldB with an alpha field (AfieldC) and fulfilled the result into field D already set in the form-
How i can do this concatenation and also the update info this field D-
Those 4 fields will be recorded into the database after saving
thanks for your help
regard
yann