Insert dynamic content in static Text

Good morning! Been searching the Forum, but i didn’t find any hint… I am sure, my request is pretty simple for some of you, but for me… i am just starting with wix :slight_smile:

Maybe someone of you guys can help:
I have a dynamic page and a database aka collection. Let’s say i have a text-element, how can i combine static text with dynamic text in this element? i know how to connect a text element to dynamic data only - but how to combine? e.g.: “I am the static Text and here goes the dynamic part {Database_Table}”

I’d be very happy, if one of you could give me a short instructions on how to do that - if possible !

thank you all in advance!

Hi Andre and welcome to Wix Code,

As the first part is the static text, and the second part is the one you connect with the dataset, you can place 2 text elements beside each other. First one holds the static text, second one you can connect it to the dataset.

Hope this helps!


Hi Mustafa,

thanks for your fast reply!

Unfortunately, this doesn’t help me much. Since i want to place dynamic content (text) in between static text, i can’t work with two seperate text-elements.

Is there any other way, maybe with wix code?


Oh sorry, i just gave you a solution based on your example. However, in this case you can get the current item instead of linking the element with the dataset. So get the current item → get the data from the field you want → assign it to the text and combine them with " + " sign. So your code should look something like this :

$w.onReady( () => { 
$w("#dynamicDatasetName").onReady( () => {
 let description= $w("#dynamicDatasetName").getCurrentItem().text;//text is the field you want to get its text
 $w("#text").text = "first static text" + description + " second static text" ; 
  } );
   } );  

Hope this is what you looking for!



Dear Mustafa,

that brings me further a little bit :slight_smile:
Unfortuanetely the output shows “undefined”…

Any idea, where to look for the error?


Sorry, i got it :slight_smile: I used field names instead of field keys - so, now it works! thank you :slight_smile:

1 Like

Does this work with Buttons also? I tried with both text and buttons. with text it works fine but gives error in last line saying “text does not exists on ‘#Button1’”

@readerssection can you specify more what are you trying to do ?
the error you mentioned, most likely because you assigning .text property to a button, which is wrong! if you want to assign a text to a button you should use .label

Hope this is what you meant!


1 Like


Thanks… it worked :slight_smile:
Sorry I am not a programmer and new to code.

Furthermore, Can you guide me if I want to collapse this button if the field of the current item.text is empty or blank?

Thanks again

Dear Mustafa
I would like to do the same thing but simply that the dynamic text uses the value of an element of my repeater is it possible? Thank you for your answer

Old post closed as you have asked duplicate question in a new post.