get current item dynamic page id and display in user input box

hello, like the title says, i’m looking to get my site to collect the dynamic page’s id and display it in a user input box for a form that submits to another data collection. to be more clear, i have a dynamic page and on each page is a user submission form that submits to another data collection. I want the user submission form to collect the current id of the page it’s on and be a “pre-filled” input field

i’d be happy to provide more context or screenshots if needed, thank you!

Hi,

You can set this up pretty easily using Corvid.

You can use a dataset onReady() and getCurrentItem() to determine what item page is currently being viewed.

Depending on the field you want to already be filled out in the input box automatically you would then just assign that value to the input box.

In the example below it pulls from the field “Favourite Genre” from the item in the collection that the dataset is connected to and prefills an input box with the value.

$w.onReady(function () {
    $w("#dynamicDataset").onReady(() => {

 let itemObj = $w("#dynamicDataset").getCurrentItem();

        $w('#input1').value = itemObj.favouriteGenre;

    });

})

I hope this helps!

Dara | Corvid Team

1 Like

Thank you so much it worked perfectly
<3

DJ bon26

For me getCurrentItem() returns the last element in the dataset and NOT the current one that is being viewed in the dynamic page.

Any suggestions?
thanks.

Dan Yarden any luck with your problem solution ?

Awesome worked for me as well

Thanks it worked