Using wixLocation.query Results/Items

Can someone help me understand what I am doing wrong? I am trying to create a link that autofills data based on its query parameters.

So I have one form on a page that on submit, sends the user to:

wixLocation.to("/race-entry-form-payment-slip?total=" + total + "&ParentFirstName=" + $w("#inputParentFirstName").value + "&ParentLastName=" + $w("#inputParentLastName").value + "&ParentEmail=" + $w("#inputParentEmail").value + "&StudentFirstName=" + $w("#inputStudentFirstName").value + "&StudentLastName=" + $w("#inputStudentLastName").value);

It sends them to the page, but doesn’t seem to fill in the information. Here is the code and UI I used:


I also tried doing:

let items = query.items;
let total = items[0]
let ParentFirstName = items[1]
//and so on...

…but that didn’t work either.
Could someone explain to me how to use the information from a link query? And set them as variables to use in code.

Thank you,
Mitchell

Never mind, I figured it out. Here is the code I used just in case anyone else is lost. I wish this was in the API documentation.

import wixLocation from 'wix-location';
$w.onReady(function () {
	let query = wixLocation.query;
	let total = query.total;
	let ParentFirstName = query.ParentFirstName;
	let ParentLastName = query.ParentLastName;
	let ParentEmail = query.ParentEmail;
	let StudentFirstName = query.StudentFirstName;
	let StudentLastName = query.StudentLastName;
	$w("#text3").text = "Total: $" + total + "\nParent Name: " + ParentFirstName + " " + ParentLastName + "\nParent Email: " + ParentEmail + "\nStudent Name: " + StudentFirstName + " " + StudentLastName;
});
1 Like

Just what I need! But the int the last line
$w(" #text3 “).text
should be
$w(” #text3 ").value