How is it possible to update a collection from input fields?

I tried to follow another user’s code, but the first string is not executed:

export function button1_click(event) {
    $w('#button1').label = "Updating..."
    wixData.get("Anagrafe2", $w('#input4').value)
        .then((result) => {
            result.piva_cfscl_contraente = $w('#input4').value
            result.nominativoContraente = $w('#input2').value
            result.comuneIstat = $w('#input21').value
            result.codiceProvincia = $w('#input20').value
            result.codiceCap = $w('#input7').value
            result.indirizzoContraente = $w('#input8').value
            wixData.update("Anagrafe2", result)
                .then(() => {
                    $w('#button1').label = "SUCCESSO"
                    $w('#button1').style.backgroundColor = "#45b6fe"
                    $w('#button1').style.color = "#FFFFFF"
 
 //return to orginal button
                    setTimeout(function () {
                        $w('#button1').label = "MODIFICA CLIENTE"
                        $w('#button1').style.backgroundColor = "#B6F3E8"
                        $w('#button1').style.color = "#000000"
 
                    }, 1000)
 
                })
        })
        .catch((error) => {
            $w('#button1').label = "ERRORE"
            $w('#button1').style.backgroundColor = "#FF0000"
            $w('#button1').style.color = "#FFFFFF"
 
 //return to orginal button
            setTimeout(function () {
                $w('#button1').label = "MODIFICA CLIENTE"
                $w('#button1').style.backgroundColor = "#B6F3E8"
                $w('#button1').style.color = "#000000"
 
            }, 1000)
        });
 
}

You’re using the same value for _id (in the get() method) and for the piva_cfscl_contraente. I guess that’s wrong.

How can I write the string to tell the inputs when a new name is written to take that particular line and update it?

wixData . get ( “Anagrafe2” , ?? )

I don’t understand the question.
Do you want to query the data collection and to find the record where the name field is equal to the input value?

I need to tell the input box that if it finds that VAT number or tax code, it makes me update them in the inputs

present in the Anagrafe2 collection

@makeitsassari Sorry, but I don’t understand your description. Maybe someone else will.