dynamic product title in to input

hey,
I am trying to get the dynamic product title and set it in to contact form, to the input.
i try this

import {local} from 'wix-storage';

let name

$w.onReady(function () {

let item = $w('#dynamicDataset').getCurrentItem();
name = item.title;

let word = name.value;
    local.setItem("productName", word);
 var sameWord = local.getItem("productName");
    $w("#input7").value = sameWord;
    $w("#input7").placeholder = sameWord;

});

but its give me undefined instead of the product title


someone can help pls?

thanks,
yair

The dataset might not be ready yet. See the dataset.onReady() API .

1 Like

Hey @yisrael-wix thanks,

but it’s still undefined

import {local} from 'wix-storage';

let name

$w.onReady(function () {
       $w('#dynamicDataset').onReady(() =>{ 
let item = $w('#dynamicDataset').getCurrentItem();
name = item.title;

let word = name.value;
    local.setItem("productName", word);
 var sameWord = local.getItem("productName");
    $w("#input7").value = sameWord;
    $w("#input7").placeholder = sameWord;
 console.log("The dataset is ready");   
 }); 
});

@yisrael-wix Hey, I managed to take over the problem, thanks anyway

@topink-webmaster
You don’t need name.value . It should be like this:

name = item.title;
local.setItem("productName", name);