# How do I autofill a textbox in a form with the current dynamic page url?

**URL:** <https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793>\
**Category:** Ask the community\
**Tags:** wix-studio, code\
**Created:** [June 8, 2024, 12:11pm UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793 "2024-06-08T12:11:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_Meeuwes](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bart_meeuwes/32/82234_2.png) [@Bart\_Meeuwes](https://forum.wixstudio.com/u/Bart_Meeuwes)\
**Post date:** [June 8, 2024, 12:11pm UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/1 "2024-06-08T12:11:59Z")

</div>

Hey community!

I am relatively new to the velo coding and want to implement a seemingly super easy piece of code.  
I am creating a website for a vacation rental website and I’ve got dynamic pages set up with filters that all work perfectly. Now the thing is that I am building the page of the Item Details page where you can see the description, pictures, etcetera… I have added a form for visitors to fill in when they would like more information, would like to book their stay.  
On this form I have a textbox called “link” and this should be filled automatically when sending the form with the current dynamic page’s url. So we get the exact url the visitor was interested in.

I am building in Wix Studio and I tried this code but I can’t seem to find the correct ID for the field on the form…

import wixData from ‘wix-data’;  
import wixLocation from ‘wix-location’;

$w.onReady(function () {  
let url = wixLocation.url;  
$w(" #link ").value = url.toLocaleString()  
});

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [June 8, 2024, 1:48pm UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/2 "2024-06-08T13:48:25Z")

</div>

Hi Bart,

Do you have some other code on the page as well, apart from this? If not, then you don’t need **wix-data**.

> [@Bart\_Meeuwes](#):
>
> I am building in Wix Studio and I tried this code but I can’t seem to find the correct ID for the field on the form…

You can find the ID by clicking on the text input box and the properties panel will show up on the bottom right.

 ![](https://us1.discourse-cdn.com/wix/original/3X/d/7/d72582ff7405f9056c369e7971be98df1a124330.png)  
 ![](https://us1.discourse-cdn.com/wix/original/3X/6/3/6384db147f95b2637389e91de18a529410ba92df.png)  
In the above example, **#smartSpeakerImage** is the ID of the image element.

And I’d recommend that you use the new **wixLocationFrontend** API instead.

```javascript
import wixLocationFrontend from 'wix-location-frontend';

$w.onReady(function () {
    let url = wixLocationFrontend.url;
    $w("#myElementId").value = url;
});

```

> **P.S.** I’m not sure if this will work with the new Wix Forms.

---

<div class="post-metadata">

**Author:** ![Bart\_Meeuwes](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bart_meeuwes/32/82234_2.png) [@Bart\_Meeuwes](https://forum.wixstudio.com/u/Bart_Meeuwes)\
**Post date:** [June 8, 2024, 3:29pm UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/3 "2024-06-08T15:29:08Z")

</div>

Hey Pratham  
Thank you for taking the time to answer but this is not working. As you’ve mentioned in the PS it is indeed the new wix forms and I can’t see the ID for the individual fields of the form as in the previous builder.

---

<div class="post-metadata">

**Author:** ![codequeen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/codequeen/32/88960_2.png) [@codequeen](https://forum.wixstudio.com/u/codequeen)\
**Post date:** [June 9, 2024, 8:24am UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/4 "2024-06-09T08:24:36Z")

</div>

Wix Forms is not codable.

You will have to build your firm using input elements AND you must set field value on the dataset (not set value to input element) in order to actually capture that data.

---

<div class="post-metadata">

**Author:** ![Bart\_Meeuwes](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bart_meeuwes/32/82234_2.png) [@Bart\_Meeuwes](https://forum.wixstudio.com/u/Bart_Meeuwes)\
**Post date:** [June 9, 2024, 4:35pm UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/5 "2024-06-09T16:35:34Z")

</div>

Seemingly super easy as I thought… Never thought it would be that simple…  
Thanks for the help.  
This code worked perfectly and used this guide for the custom form building

> **[CMS: Creating a Custom Form with Input Elements that Submit to Your Collection...](https://support.wix.com/en/article/cms-creating-a-custom-form-with-input-elements-that-submit-to-your-collection?tabs=Studio-Editor,Studio-Editor-2,Studio-Editor-8,Studio-Editor-11)**
>
> Create a custom form that allows visitors to use input elements to submit their info directly to your CMS collections. Input elements include text boxes, dropdo

import wixLocation from ‘wix-location’;

$w.onReady(function () {  
let url = wixLocation.url;  
$w(“#link”).value = url.toLocaleString()  
});

---

<div class="post-metadata">

**Author:** ![noahlovell](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/noahlovell/32/118920_2.png) [@noahlovell](https://forum.wixstudio.com/u/noahlovell)\
**Post date:** [August 20, 2024, 11:08am UTC](https://forum.wixstudio.com/t/how-do-i-autofill-a-textbox-in-a-form-with-the-current-dynamic-page-url/59793/6 "2024-08-20T11:08:43Z")

</div>

Split this topic on August 20, 2024, 11:08am UTC

A post was split to a new topic: [Style Text according to path](https://forum.wixstudio.com/t/style-text-according-to-path/62058)
