I have an upload button with a submit button. I also have a dropdown connected to the same submit button. The drop down labels and values are connected to another dataset. I have an onlclick that loads the dropdown as I do not want the user to have to do it and I plan to hide it once this works. Right now it looks like the correct item is chosen but when I submit the center_id is blank. Any thoughts?
$w.onReady(function () { $w("#MemberCenter").onReady(() => { $w("#repeater1").onItemReady(($item, item, itemData, index) => { $item("#addCenterFiles").onClick((event) => { $w("#centerID").selectedIndex = itemData }); }); }); }); $w.onReady(function () { $w("#myUploadButton").fileType = "Document"; $w("#repeater1").onItemReady(($item, item, itemData, index) => { $item('#myButton').onClick(() => { if ($w("#myUploadButton").value.length > 0) { console.log("Uploading " + $w("#myUploadButton").value[0].name); $w("#myUploadButton").startUpload() .then((uploadedFile) => { console.log("Upload successful. File is available here:"); console.log(uploadedFile.url); }) .catch((uploadError) => { console.log("File upload error: " + uploadError.errorCode); console.log(uploadError.errorDescription); }); } else { console.log("Please choose a file to upload.") } }); }) })
Hey Bill,
I think there may be an issue with how you're accessing the item. Without knowing the structure of your DB, I'd point you to two things quick 1. Your onItemReady callback function has the wrong parameters. The three parameters should be the $item selector, the item object (the name doesn't matter) and index.
$w("#repeater1").onItemReady(($item, item, itemData, index)
should be
$w("#repeater1").onItemReady(($item, itemData, index)
2. Check out the value that you're setting. You could be setting $center_id as the value, when it's really the label.
Let me know if this helps.