I am wondering whether I can connect 1 user input to multiple wix datasets.
The detailed situation is like this. I am creating a registration form for registering classes. In the form, I will collect some personal details from the client and also class registration details. There are too many personal details (columns) in one dataset. And for each type of class, I am collecting different information (from dropdown list / checkboxes) in the class registration section. Therefore, I want to separate the dataset into sth like “personal details”, “class A”, “class B” datasets.
For class A and class B datasets, I also need to get (at least) the name of the registrant which is filled in from the personal details section. But for now I can connect the "name’ input with only the “personal details” dataset, but not the others at the same time. So I wonder how it could be done? Thank you
When someone hits SAVE you can take any information you want and save that to as many datasets as you want. Add the datasets to the page like #dataset2 and so on…
When you want to set a value in the other dataset use
Then you just use $w(“#dataset2”).save() when you want to save it. If you want to use new records you need to create one using .new() first before setting field values.
I suggest you to write in code , two functions that will help you insert all of the user’s data to the collections.
First, add an event handler function that runs when the submit button’s clicked.
In the function create an object for each collection and include all the relevant fields.
Second, create a function that gets as parameters an object and database’s name, and uses function Insert() in order to add an item to the collection.
Here you can read about this function.
Send each object from the first function to the second one, and by that you will be able to insert all the user’s data to multiple datasets.