I have created a CMS database and dataset. I have a page that has input fields connected to the CMS database. I am also displaying a table of the database below the inputs. When I set the dataset to “Write” I am able to input the info but it will not display in the table below. When I set the dataset to “Read and Write” the entries show up in the table, but the last entry is in the input fields already. If you change them and submit, it overwrites the last entry.
Basically, I am trying to have input fields that submit to a table that is visible on the same page. Is this possible? Btw, I don’t have any experience with code.
Hi Kevin,
Don’t worry, you just have to follow the steps below and copy paste the exact same code.
- For Wix Studio: Click on the { } icon from the side menu and then click on Start Coding.
For Wix Editor: Turn on Dev Mode.
- You need to have two separate databases, one that is set to Write Only and is connected to the input fields, and one that is Read Only and is connected to the table on the same page. While setting up these datasets, open the Dataset Settings and change the Dataset IDs to
datasetWrite
and datasetRead
respectively.
- Make sure the click action of the Submit button is set to Stay on the same page.
- Now simply clear the default page code in the code panel and paste the one provided below and test it out:
$w.onReady(function () {
$w('#datasetWrite').onAfterSave(() => {
$w("#datasetRead")
.refresh();
});
});
Hope this helps!