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?
Thanks
Dan
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
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.
Enjoy
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); }
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", "test@gmail.com") 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?
Regards
Dan
something like this...
//change collection id and field keys as necessary
wixData.query("MemberProfile") .eq("emailAddress", "test@gmail.com") .limit(1) .find() .then((results) => { let allResults = results.items; // number of times email appears in the user database should be 1 console.log(allResults); let firstResult = allResults[0]; //console.log(firstResult); let firstName = firstResult.firstName; console.log(firstName);
$w('#input7').value = firstName;