How to auto create URL with value from collection

I have form with 2 fields (Student id & Class id) it is connected to Studenid-Classid collection.
I want make a trigger, when visitor click “Next Step” button, it auto create URL and redirect visitor to that URL, the URL example:
https://www.example.com/valuename1=NUMBER OF STUDENT ID FIELD&valuename2=NUMBER OF CLASS ID FIELD
what is the code? Please help

Hey
Of course, hope this code helps you.

let newUrl = "https://www.example.com/valuename1=" + $w("#studentIdFieldId").value + "&valuename2=" + $w("#classIdFieldId").value;
// That is the url you want
wixLocation.to(newUrl); // This will redirect the user to that url
1 Like

thank you very much, i have replace studentIdFieldId and classIdFieldId with right field id (input1 and dropdown1) but it show this “ReferenceError: wixLocation is not defined”
What did i miss?

@gongoldgoal
You need to import it:

import wixLocation from 'wix-location';

Good luck!
Roi.