Submit Dynamic Page (Dynamic data set) content and user inputs to a data set

Hi everybody,

I have created a booking system for a dance school. It works with dynamic pages, i.e. there is data set “classes” containing the course information and the course dates.
https://www.tanzschule-ampark.ch/Tanzkurse/Anmeldung_Paartanz-Starter-L
Then on the dynamic page there is a user form, that the customer has to fill in order to book the class. So on the dynamic page there is another data set “bookings” for the user inputs, i.e. if the user clicks the submit button the content of input forms is written into the “bookings” data set. However what is still missing is that the course ID, which is in the dynamic data set “classes” is also written into the “bookings” data set such that the owner knows which class the customer has booked.
As far as I understood this has to be done with wix code using " getCurrentItem". However I have not found a code example for this specific problem and I am pretty new on this topic.
I would be happy for a simple code example how to write content of a dynamic page/data set to another data set on form submission.

Thanks a lot and best wishes,
JayJay

Why don’t you just place an input box on your dynamic page and link it to the course ID field in your “classes” collection. Then on submit just pass that input value to the “bookings” collection along with the rest of the form data ?

Hi Mike,

thanks a lot for you comment. Am I wrong or wouldnt this mean that I need to connect that input box to 2 data sets at the same time? First, to the dynamic data set “classes” that is used for creating the dynamic page in order to fill the course ID in to the input box and 2nd to the data set “bookings” in order to pass it there.

Best wishes,
JayJay

@jakicjosip
Yes connect the input to the course ID field in your “classes” collection. The pass the input value to your “bookings” collection with the submit button…

$w.onReady( function () {

$w(‘#submitButton1’).onClick((event) => {

let courseId = $w(‘#input1’).value;

$w(‘#bookingsDataset1’).setFieldValue(‘fieldNameInBookingsDataset’, (courseId));

    $w('#bookingsDataset1').save(); 

}) 

})

@mikemoynihan99 Wow thanks a lot!! I am going to try that at home this evening!

@mikemoynihan99
Hi Mike,

I tried to follow you instructions. For testing purposes I just wanted to pass any string to the booking data set. Here is the code I used:

$w.onReady( function () {

$w(“#button1”).onClick((event) => {

$w(“#dataset1”).setFieldValue(“kursID”, “test”);

    $w("#dataset1").save(); 

}) 

})

Then I get the following error message:
" save operation failed: DatasetError: Operation (save) not allowed during save "

Could you help me on that?

Best wishes,
Joe

@jakicjosip
Remove $w(" #dataset1 ").save();

@mikemoynihan99
It woooooooorks!! Thanks a lot Mike for the lightning fast response! You made my day!

@jakicjosip
you’re welcome

Dear All,
am also stuck on same kind of thing. Patient selected one of the centre as his choice for undergoing a test. The selected details are displayed on a dynamic page, same page has booking details with another data set. with Wix form am able to get details submitted by patient such as name,age etc but not able to get the information about which centre and test did he chosen.
How do I combine both of these data and get a combined alert on mail. Mail received only gives data submitted on form.

Please help me out with code as am stuck on this for many days and not getting desired result.

Hi there, I’m not sure whether you are still working on this question. However, the below code works on this

$w.onReady( function () {

$w( ‘#button’ ).onClick((event) => {
let courseId = $w( ‘#textbox’ ).text;

$w( '#dataset1' ).setFieldValue( 'field title' , (courseId)); 
       $w( '#dataset1' ).save(); 

} );