Clean field after validation

Hi

This is my page :

and here is the code behind this page:

import wixData from ‘wix-data’;

export function save() {
//
wixData.query(‘Artistes’)
.eq(‘title’, $w(‘#input14’).value)
.find()
.then(res => {
let firstItem = res.items[0];
let toInsert = { “artiste”: firstItem._id, “inputArtist”: $w(“#input14”).value, “title”: $w(“#input11”).value, “annee”: $w(“#input9”).value, “languePrincipale”: $w(“#input10”).value, “duo”: $w(“#input12”).value, “live”: $w(“#input13”).value };
console.log(toInsert);
wixData.insert(“Titres”, toInsert)
.then((results) => {
console.log(results);
})
. catch ((err) => {
console.log(err);
});
});
}

When I fill in my form and validate, it works very well, except that it leaves the validated data displayed. (However, they are correctly entered in the database)

Which code should I add (and where? (I am a beginner))) so that when I validate, the form becomes blank again.

Thanks in advance for your help

Up

Hi Karl

in your '.then(())=>{ IN HERE } after the values have been inserted in the database, simply set your input fields value to nothing like this:

$w("#input1").value = "";

Tiaan

Thanks, but don’t work… Where Am I Wrong ?

import wixData from ‘wix-data’;

export function save() {
//
wixData.query(‘Artistes’)
.eq(‘title’, $w(‘#input14’).value)
.find()
.then(res => {
let firstItem = res.items[0];
let toInsert = { “artiste”: firstItem._id, “inputArtist”: $w(“#input14”).value, “title”: $w(“#input11”).value, “annee”: $w(“#input9”).value, “languePrincipale”: $w(“#input10”).value, “duo”: $w(“#input12”).value, “live”: $w(“#input13”).value };
console.log(toInsert);
wixData.insert(“Titres”, toInsert)
.then((results) => { $w(“#input14”).value = “”, $w(“#input11”).value = “”, $w(“#input9”).value = “”, $w(“#input10”).value = “”, $w(“#input12”).value = “”, $w(“#input13”).value = “” };
console.log(results);
})
. catch ((err) => {
console.log(err);
});
});
}

Looks fine, I would just remove the commas and replace it with ‘;’

I replace the commas, but same error :

I can’t seem to open this image from the forum, kindly send it to me at tiaan@wix-coders.com