Code to submit database field to 2 input elements

Question:
I have the below code on my website, that adds database content to input elements. It works in this setup:

const currentItem = $w(“#dynamicDataset”).getCurrentItem();
$w(“#input22”).value = currentItem._id;
$w(“#input36”).value = currentItem.itinerary;

It works, but now I need to enter the “currentItem._id” not only to #input22, but also to #input37. The reason that I have to add it to another input element, is that I have 2 forms on my page that need to process the _id individually. I tried to add the below line but than the entire code doesn’t work anymore:

$w(“#input37”).value = currentItem._id;

Can anybody help me rebuilding the code so I can add the currentItem_id to 2 text elements on the same page?

Thanks in advance!

Product:
Wix Studio

Well, technically if you’re able to insert the ID in input22, you should very much be able to insert it in input37 as well.

The fact that you’re not able to - may be due to a logical error.

That is, you might have written this:

outside the scope brackets. So try writing this line immediately below the other code, for example:

const currentItem = $w(“#dynamicDataset”).getCurrentItem();
$w(“#input22”).value = currentItem._id;
$w(“#input37”).value = currentItem._id;
$w(“#input36”).value = currentItem.itinerary;

Also make sure you’re written this code inside the onDatasetReady function. Using await is recommended.

If it still does not work, try checking the settings of input37 and make sure it is not set to Read Only.