Code to rename a text field with FirstName + LastName

I am not good with Javascript but learning…On a page load, I have a text field (Not an input field) that is called FULL NAME. I have a database called Members and in it 2 field called LastName and FirstName.

I would like that on Page Load of my Dynamic page, the textfield called #fullname contain Firstname and Lastname.

:slight_smile:

Hi,
Should be relatively easy :slight_smile:
I assume you have a dataset called ‘#dynamicDataset’.

This should work:

$w.onReady(function () {
    const currentItem = $w('#dynamicDataset').getCurrentItem();
    $w('#fullname')  = `${currentItem.FirstName} ${currentItem.LastName}`
});

Hope this helps,
Liran.

Wowww… Easy one :slight_smile: Thanks a lot :slight_smile:

Just to let you know, It didn’t work the way you gave it to me…I had to modify it a bit. Here is my code (Based on your code) that is working

$w.onReady(function () {
const currentItem = $w(‘#dynamicDataset’).getCurrentItem();
$w(“#nomcomplet”).text = ${currentItem.firstname} ${currentItem.lastname};
});

Thanks. All working now