Database field update onClick

Hi,

Im trying to get index number from repeater, convert it into text, and update certain text field in database after click. I think somewhere around but at the same time not there. Can someone help me? Neither loading if working or data insert.

$w.onReady(() => {
$w('#repeaterIndex').onItemReady(($item, data, index) => {
        $item('#updateRankButton').onClick(() => {

 
$w('#updateRankButton').hide
$w('#loadingGifLeaderbords').show

let currentIndex = $w('#dataset4').getCurrentItemIndex();
console.log(currentIndex);
let rankUpdate = Number(index+1).currentIndex();
console.log(rankUpdate)

$w("#dataset4").setFieldValue("rank", rankUpdate );
console.log()
$w('#updateRankButton').show
$w('#loadingGifLeaderbords').hide
})
})
})

Thank you!
@Ahmad
@J. D.

There’re a few mistakes in your code.

  1. It should be .show () , .hide () with parenthesis.

  2. This part is wrong: Number ( index + 1 ) since index + 1 is already a number.

  3. And what is . currentIndex (); ? I’m not sure what you’re trying to do in this line.

  4. And this console . log () is empty.

Thank for quick response @jonatandor35

With this code its now working, but data is inserted only for first item in collection, but now for the iteam which is in repeater. Where is problem?

$w.onReady(() => {
$w('#repeaterIndex').onItemReady(($item, data, index) => {
        $item('#updateRankButton').onClick(() => {

 
$w('#updateRankButton').hide();
$w('#loadingGifLeaderbords').show();


let currentIndex = $w('#dataset4').getCurrentItemIndex();
console.log(currentIndex);
let rankUpdate = index + 1
console.log(rankUpdate)

$w("#dataset4").setFieldValue("rank", rankUpdate );
$w('#updateRankButton').show();
$w('#loadingGifLeaderbords').hide();
$w('#dataset4').save();
})
})
})