Copy Database Linked Text to User Input ???

Background:
In a repeater I have a text field (text6) connected to a database (userStatus), this shows a users status. I also have a user input field (input1) which is connected to a different database (Comments).

What i want it to do:
I want what text6 shows from the database to be copied to input1 as a user input when a user clicks on a text box (textbox1).

The Problem:
Text6 shows the information from the database but this isnt copied to input1, instead the original text (from the editor) is copied.

Heres some pics to help - elements i am talking about are highlighted in green.

<= My Code

YES I HAVE LOOKED FOR OTHER POSTS BUT NONE HAVE HELPED

If you use repeaters then look at using the correct code so that it gets it by item etc.

See the Wix API reference for Repeater here.
https://www.wix.com/corvid/reference/$w.Repeater.html

There are a good many examples that you can view for more info with the coding.
Modify repeater items using Wix Code
How To Create and Use Repeaters in Wix Code - Wix Code Tutorial 2018
How to use Repeaters on Wix | Create Property Listing, Directory

Hi

Its not the repeater that i am having problems with it is copying the text shown in text6 to input1…

It’s looks like a bug to me or you need to rethink the logic here

You can also get the value directly from the dataset

export function textBox1_click() {
  let user = $w('#dataset1').getCurrentItem();
  $w('#input1').value = user.userName;
}

@firstplacevape In your opening post you said #text6 was in a repeater. So is it or isn’t it? If it is I think your code is wrong and givemeawhisky’s first link explains why.

@lee1 Yes it is in a repeater, maybe he is right tbh im new to this coding side and im still wrapping my head around it, ill check it out again and see what i can make of it

Thats great! thank you but if i want to change the value how would i change that? can i swap out user.username simply with the field id?

Thank you i have figured it out now on how to change it :smiley:

:frowning: Now im having the issue where the input1 is the same on all parts of the repeater, is there a way to have this filtered by whats in text6?

@firstplacevape This might be what you’re looking for. It’s hard to be sure about how the elements you’ve mentioned relate to one another. Again, the link above explains selector scope.

export function textBox1_click(event)
{
	const $item = $w.at(event.context);
	$item('#input1').value = $item('#text6').text;
}

@lee1 OMG this is exactly what ive been trying to do! Thank you so much its working perfectly :smiley:

You can use .at selector
to select a specific instance in a repeater and connnect with it

One was using $w at

export function textBox1_click(e) {
  let $item = $w.at(e.context);
  let user = $item('#dataset1').getCurrentItem();
  $item ('#input1').value = user.userName;
}

second way using forEach Loop

$w('#repeater').onItemReady(($item, itemData, i)=>{
    let user = $item('#dataset1').getCurrentItem();
    $item ('#input1').value = user.userName;
});