Repeater question!

Hi everyone!

I’m stuck on a probably very simple coding part for my website.
What i wanted to do first was to replace text of a text box inside a repeater using coding.
I did great for this part.

There is my actual code:

$w.onReady( async function () {
var today = new Date();
var birthdate = new Date($w(“#text21”).text);
var msPerDay = 364 * 24 * 60 * 60 * 1000;
var age = (today.getTime() - birthdate.getTime()) / msPerDay;
var age = Math.round(age);
$w(“#text20”).text = age.toString();
})

This code get the birthdate value inside text box #text21 and return it to age (number) in textbox #text20.

My problem is that my code take only the value of the first container and return the result in every other containers in the others textbox #text20.

I want that each container use the code for his “own data”

Anyone can help me with that?

coding:

result:

You need to implement an onItemReady() function for your Repeater. See the Repeater API for more information on using Repeaters.

Thanks for the clue Yisrael! I took a look at this function yesterday but I don’t have any idea how to integrate my code to the onItemReady() function… :sweat: Any idea how to start it? or any easy example? This is my first time coding a website using Java with Wix. Plus, I’m French so the tutorial isn’t easy to understand! :sweat: Big thanks in advance!

@apocalyptus Corvid uses JavaScript, not Java. They are 2 different languages. You can view the library of Corvid Examples .

Also checkout the Tips & Updates page which has a lot of examples.

You can also checkout a popular YouTube channel for tutorials: Code Queen

If even that doesn’t do it, checkout the Wix Arena , its a hub for Corvid & other experts.

Big thanks guys! After many try, I finally made it!

I used forEachItem instead and it worked!

$w.onReady( async function () {
$w(“#repeater1”).forEachItem( ($item) => {
var today = new Date();
var birthdate = new Date($item(“#text21”).text);
var msPerDay = 364 * 24 * 60 * 60 * 1000;
var age = (today.getTime() - birthdate.getTime()) / msPerDay;
var age = Math.round(age);
$item(“#text20”).text = age.toString();
});
})