Tracking URL when a multistage form is submitted

Hello guys I really need help !

I have a contact form on dynamic pages. I need to know wich item the user has submitted the form on.
At the begining I had a simple form and my code was:

import wixLocation from ‘wix-location’ ;
let url = wixLocation.url;

$w.onReady( function () {
$w( “#dataset3” ).onBeforeSave(() => {
$w( “#dataset3” ).setFieldValue( “currenturl” , url);
});
});

This worked perfectly : when the user submitted the form, i got the url - from where he submitted the form - in the field “current url” of my dataset 3.

But now I have to create a multi step form. I tried to implement the same code but it didn’t work. I tried a lot of other things all day and it still doesn’t work.

I’m a complete beginer and I have to make it work quickly :sweat_smile:.

Thank you very much for your time :blush:

1 Like

I also tried :

$w.onReady( function () {
$w( “#button19” ).onClick(() => {
$w( “#dataset7” ).setFieldValue( “urlpage” , url);
});
});

$w.onReady( function () {
$w( “#button19” ).onClick(() => {
console.log(url);
});
});

But it didn’t work.

However when I click on the button #button19, I get the url in my console. So I guess there is a problem there :
$w( " #dataset3 " ).onBeforeSave(() => { $w( " #dataset3 " ).setFieldValue( “currenturl” , url);

I forgot to say something :
When I created my first form, I didn’t use a Wix Form. I used fields and connected them to a dataset.
Now that I have to create a multistep form, I need to use a Wix form because I don’t know how to do it myself. I don’t think that my code doesn’t work because it’s a multistage form. I think it’s because it s a Wix form. Indeed I try with a simple Wix form and it doesn’t work.

Hey,

I have the same problem. Have you find a solution ?