Help in update a repeater


i am a beginner in in programing so bear with me please
this is a repeater , with 4 inputs should carry and view data from collection called visits

i did view visits data in a input so that i can change the values of a certain field, and there is a button to trigger the changes.

but i am so stupid and have no knowledge but i am trying my best to learn.

this is my code i know its a very ugly and stupid code , but really can use some help because it does not work :sob:

export function repeater1_itemReady($W, itemData, index) {
    $w('#button3').onClick(() => {
        console.log('1 pass')
        const item = itemData
        const h = item._id
        console.log(h)
        
        itemData.detail = $w('#textBox1').value
        itemData.quadrant = $w('#input4').value
        itemData.premeasure = $w('#input3').value
        itemData.toothnumber = $w('#input2').value

        let toUpdate = {
            "_id": h,
            "date": "Mr.",
            "detail": $w('#textBox1').value,
            "quadrant": $w('#input4').value,
            "premeasure": $w('#input3').value,
            "toothnumber": $w('#input2').value
        };

        wixData.update("visits", toUpdate)
            .then((results) => {
                let item = results; //see item below
            })
            .catch((err) => {
                let errorMsg = err;
            });
    })

Try this one… (not tested)…

import wixData from 'wix-data';

$w.onReady(function () {
    $w('#repeater1').onItemReady(($item, itemData, index)=>{    
        $w('#button3').onClick(()=> {console.log('1 pass');     
            itemData.detail = $item('#textBox1').value
            itemData.quadrant = $item('#input4').value
            itemData.premeasure = $item('#input3').value
            itemData.toothnumber = $item('#input2').value

            let toUpdate = {
                "_id": itemData._id,
                "date": "Mr.",
                "detail": $item('#textBox1').value,
                "quadrant": $item('#input4').value,
                "premeasure": $item('#input3').value,
                "toothnumber": $item('#input2').value
            };
            wixData.update("visits", toUpdate)
            .then((results) => {let items = results; console.log(items);})
            .catch((err)=>{let errorMsg = err;});
        }); 
    });    
});

Else you would have a second option to use forEachItem…

it acutely works
woow

but it seems the same code as mine

where is the deference , where my is the fault in my code?
so that i will note repeat it again

@yaser1999yaser
Simply do not use the coding-way you did all the time until today.
Change your coding-style to a better one.

DO NOT USE —> Export-Functions …

export function repeater1_itemReady($W,itemData,index){ ... }

Use the more compact and more simple way like i did in my example, placing all your code into the …

$w.onReady(function(){
	// all your code here....
});

This has several advantages, believe me.

Use Export-Functions only in the back-end.

@russian-dima thank you thank you thank you thank you so much
i wish you have a great day because you made my day thank you again