Help Needed: Rating & Testimonial Lightbox

Hello! I have an online directory business and am looking to build a rating and testimonial section on each business that has paid to be listed on my site. Each business has a profile (dynamic page) and will display rating and testimonials from a collection.

My challenge is the ‘Rate Vendor’ button lives on a dynamic page and, when triggered, will lead you to a lightbox that allows you to enter your rating and testimonial. I have built a collection that captures the user input from the lightbox and a section on the vendor profile page to display it.

My question is - How do I get the company’s name to be associated with the user input when the rating/testimonial lightbox is triggered from a dynamic page? As it stands now, data that is entered by the user is sent to the collection without the company’s name they are rating. Screenshots below:
Testimonial/Ratings Lightbox - https://share.getcloudapp.com/o0ukb7Qo
Dynamic Vendor Profile Page - https://share.getcloudapp.com/jkuJ2EyE
The live site is here - https://www.findlegalvendors.com

Is there anyone that can help?

Thanks in advance!

If it’s coming from a dynamic page you should know which Vendor they are browsing. How do code that… I’m unsure =)

Is there a way to have a field on the dynamic page travel to the Lightbox and auto populate?

Hey,

You can transfer the company name by sending over the data to the lightbox like this:

$w("#myButton").onClick( (event) => {
      let data = {
         companyName: $w("#hereGoesTheCompanyName").text
      };
      wixWindow.openLightbox("LightboxName", data);
});

Then on the lightbox you can set a text element’s value to the company name like this

$w.onReady( function() {
    let data = wixWindow.lightbox.getContext();
      $w("#textElement").text = data.companyName;
} );