# How to get title from dynamic page after form submission?

**URL:** <https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507>\
**Category:** Ask the community\
**Tags:** wix-forms, question, code\
**Created:** [October 22, 2020, 3:06pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507 "2020-10-22T15:06:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpsanchez0514](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jpsanchez0514/32/8740_2.png) [@jpsanchez0514](https://forum.wixstudio.com/u/jpsanchez0514)\
**Post date:** [October 22, 2020, 3:06pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/1 "2020-10-22T15:06:11Z")

</div>

Hi!!

I have a dynamic page in my site in which there are forms a user can submit. Is there a way in which i can know exactly from which site a given user typed/filled the form?

Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [October 22, 2020, 3:47pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/2 "2020-10-22T15:47:01Z")

</div>

Are you refering to [getCurrentItem](https://www.wix.com/corvid/reference/wix-dataset/dynamicdataset/getcurrentitem)

#dynamicDataset - dynamic Dataset

```javascript
$w.onReady( () => {
 $w("#dynamicDataset").onReady( () => {
    let currentItem = $w("#dynamicDataset").getCurrentItem().title;

  } );

} );

```

---

<div class="post-metadata">

**Author:** ![rinshulgoel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rinshulgoel/32/22503_2.png) [@rinshulgoel](https://forum.wixstudio.com/u/rinshulgoel)\
**Post date:** [October 22, 2020, 5:38pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/3 "2020-10-22T17:38:38Z")

</div>

This might help -

```javascript
import wixLocation from'wix-location';

export function submit_onClick(events){
    let prefix = wixLocation.prefix;
    let path = wixLocation.path;
    
    $w("#collectionName").setFieldValue("path" , path);
    $w("#collectionName").setFieldValue("prefix" , prefix);
}

```

* * *

To know more about the path and the prefix visit here.  
Also when you will be using the path you must have some knowledge about arrays.

---

<div class="post-metadata">

**Author:** ![jpsanchez0514](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jpsanchez0514/32/8740_2.png) [@jpsanchez0514](https://forum.wixstudio.com/u/jpsanchez0514)\
**Post date:** [October 23, 2020, 4:00pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/4 "2020-10-23T16:00:42Z")

</div>

Hi, Rinshul! Thanks for your help!

I’m a Wix Code rookie -to say the least- so i’m still struggling a bit to catch up on some things, so apologies if i make dumb questions 😔.

Should i create a new field in my collection called path and another one named prefix?

Also, the form is located within a lightbox, so should i add a dataset to the lightbox?

Also, where can i see, after putting the code from which site the user submitted the form?

Thanks for all your help, Man!

---

<div class="post-metadata">

**Author:** ![rinshulgoel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rinshulgoel/32/22503_2.png) [@rinshulgoel](https://forum.wixstudio.com/u/rinshulgoel)\
**Post date:** [October 23, 2020, 4:38pm UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/5 "2020-10-23T16:38:42Z")

</div>

@jpsanchez0514

1. Should I create a new field in my collection called path and another one named prefix?

Ans : Yes (It is your wish that your work will be done with **prefix** or **path** or you might need **both** )

1. Also, the form is located within a lightbox, so should I add a dataset to the lightbox?

Ans : No, there is no such need but **add this code only to the onClick**  **function**  **of**  **submit**  **button**

1. Also, where can I see, after putting the code from which site the user submitted the form?

Ans : It will be displayed in your collection .

I hope it will help!!

---

<div class="post-metadata">

**Author:** ![jpsanchez0514](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jpsanchez0514/32/8740_2.png) [@jpsanchez0514](https://forum.wixstudio.com/u/jpsanchez0514)\
**Post date:** [October 27, 2020, 12:14am UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/6 "2020-10-27T00:14:02Z")

</div>

@rinshulgoel Hey man!

Thanks for all your help. I really appreciate it!

I’m trying to do it, but when putting the code on the lightbox, i get a message saying “Not a valid selector” in line 5 & 6 ($w ( “#collectionName” ). setFieldValue ( “path” , path )😉

I’m using the form’s collection ID defined on my site, but no luck… What should i do? 😪

---

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [October 27, 2020, 2:04am UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/7 "2020-10-27T02:04:26Z")

</div>

@jpsanchez0514 I think you should **not** use the collection name/id  
instead use that of **dataset’s** …  
[https://support.wix.com/en/article/adding-and-setting-up-a-dataset](https://support.wix.com/en/article/adding-and-setting-up-a-dataset)

---

<div class="post-metadata">

**Author:** ![jpsanchez0514](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jpsanchez0514/32/8740_2.png) [@jpsanchez0514](https://forum.wixstudio.com/u/jpsanchez0514)\
**Post date:** [October 27, 2020, 3:22am UTC](https://forum.wixstudio.com/t/how-to-get-title-from-dynamic-page-after-form-submission/30507/8 "2020-10-27T03:22:38Z")

</div>

Hi! I finally found a solution that worked for me…

Thanks to @rinshulgoel for the base code.

Here are a few things to note:

- Indeed, as @ajithkrr says, it is the Dataset’s ID that should be used. Not the Collection ID.

- The Dataset must be in Write Only mode.

- I had to add a .save command, so both the prefix and the path were succesfully saved to the collection.

This is what my final code looked like:

**import** wixLocation **from** ‘wix-location’ ;

export function submit\_onClick(events){  
**let** path = wixLocation.path;  
**let** prefix = wixLocation.prefix;

```
$w( "#dataset1" ).setFieldValue( "path" , path); 
$w( "#dataset1" ).setFieldValue( "prefix" , prefix); 
$w( "#dataset1" ).save(); 

```

}

Thanks everyone for helping out!!
