Auto fill user input on form from database

HI, I want to try and get a user input element on my form to auto fill from my database

User input on form = #input7 to auto fill from my database named MemberProfile field name = firstName.

Can anyone help me with the code for that?



something like this…

//change collection id and field keys as necessary


    .eq("emailAddress", "") 



    .then((results) => { 

let allResults = results.items; // number of times email appears in the user database should be 1

let firstResult = allResults[0];

let firstName = firstResult.firstName;

$w(‘#input7’).value = firstName;

Hi Mike,

Thanks for the reply, im close but cant get it to populate the input field,

Heres how it looks in my web editor , what needs to change? the input field ifor first name s now #input11

What other things to do i need to change ? whats the .eq(“emailAddress”, “”) do i need to change any of that?

i have a red ball as if there is an error i line 25,

By the way this is a page linked to a log in for a member, does that make a difference to the code? for example get first name from members profile for this logged in member?

There is another different option here, i have a dataset that is read only and is populating the input seen in photo on left with first name in it my custom members bar. cant i just take the data from #input1 and copy it to #input11?



Solved it my self if anyone’s interested

Set field value in data base based on whats in inputs. The inputs are read only connected to datasets that are filtered by logged in user this putting the right name in the inputs for you then fireing them to the database on submit.


export function Submit_click(event, $w) {
$w(‘#Checkinswrite’).setFieldValue(‘firstName’, $w(‘#input1’).value);
$w(‘#Checkinswrite’).setFieldValue(‘lastName’, $w(‘#input9’).value);
$w(‘#Checkinswrite’).setFieldValue(‘membersEmail’, $w(‘#input10’).value);



This came in handy BIG time!!!

1 Like

@hittalk Glad it helped you !!!