How to prefill/ autofill a section of a form from a button

If you want to load data into a form, the data must be stored somewhere.

Where is stored your contact-data?
When you talk about “contact-pages”, what is in your project a “contact-page”?
Is it a dynamic page? If so, then you surely will have a database, right?

When you ask questions, please always try to describe your situation as most detailed as possible, then you will also get better and faster answers.

More INPUT = more OUTPUT.

Your situation:

  1. Click on a button
  2. load data out of DB
  3. put data into form

Your way to glory…

  1. Starting your custom function by a click onto your button…
$w.onReady(()=>{
	$w('#myButton').onClick(()=>{
		myFunction();
	});
});
  1. Getting data out of DB (dynamic dataset)…
    getCurrentItem - Velo API Reference - Wix.com
$w.onReady(()=>{
   $w("#myDataset").onReady(() => {
       $w('#myButton').onClick(()=>{
           myFunction();
       });
   });
});

function myFunction() {
   let itemObj = $w('#myDataset').getCurrentItem();
   let itemID = itemObj._id
   let itemOWNER = itemObj._owner
   let itemTitle = itemObj.title
   console.log(itemObj)
   console.log(itemID)
   console.log(itemOWNER)
   console.log(itemTitle)
}

Take a look onto console. What do you get?

  1. After you have got your data out of DB now you want to put it into your form?
    Expand the function…
function myFunction() {
   let itemObj = $w('#myDataset').getCurrentItem();
   let itemID = itemObj._id
   let itemOWNER = itemObj._owner
   let itemTitle = itemObj.title
   console.log(itemObj)
   console.log(itemID)
   console.log(itemOWNER)
   console.log(itemTitle)
   
   $w('#myTextFieldElement1').text = itemID
   $w('#myTextFieldElement2').text = itemOWNER
   $w('#myTextFieldElement3').text = itemTitle
}