Hi guys, hoping for a little help. Caveat - I am not a coder at all.
I’m trying to build a user created gallery. I would prefer not to have 20 upload buttons - one for each field. I’m using the below code for my image upload button:
$w(‘#button1’).onClick( () => {
if ($w(“#uploadButton1”).value.length > 0) {
// user chose a file
console.log(Uploading '${$w("#uploadButton1").value[0].name}'
);
$w(“#uploadButton1”).startUpload()
.then( (uploadedFile) => {
console.log(“Upload successful. File is available here:”);
console.log(uploadedFile.url);
$w(“#dataset1”).setFieldValue(“image1”, uploadedFile.url);
$w(“#dataset1”).save()
.then( (item) => {
console.log(“Save successful”);
let fieldValue = item.item1;
} )
.catch( (err) => {
let errMsg = err;
} );
} )
.catch( (uploadError) => {
console.log(File upload error: ${uploadError.errorCode}
);
console.log(uploadError.errorDescription);
} );
} else {
// user clicked button but didn’t chose a file
console.log(“Please choose a file to upload.”)
}
} );
Is it possible to set the fieldValue to be the first field in a row that is empty? In this fashion, users can upload image, submit and repeat the process without overwriting their previous image. Thoughts?