Can I create a custom form that also submits the page URL

With my real estate website, users browse a directory of homes. Each home has its own listing page (a dynamic page that references a dataset.) Users should be able to contact the website admin when he/she wants to learn more about a specific house.

I have a custom form in place for users to submit Name, Phone, and Email from within a listing page. This submits to a Collection called “user_submissions”. However, as users submit their contact information I have no way of knowing which house they are interested in. Is there a way I can also submit a unique page ID with each submission? Prefer to do this without code…

1 Like

Hi,
This can’t be done without code, however, the required code is minimal:


$w("#datasetName").onBeforeSave(function() {
    $w("#datasetName").setFieldValue('pageUrl', wixLocation.url);
});

(make sure to change the names to fit your needs, and to include an “import” for wix-location)

1 Like

Hi Ohad, Hope you are going well.

I just have a quick question regarding dynamic pages. I run a website which allows visitors to browse rental cars in their area and select a vehicle they want to either book in or enquire about. (My members who are the rental companies upload their vehicles to a database which shows them on this dynamic page) How can I create a custom form which has prefilled values of that particular vehicle they selected (when they click the ‘adopt me’ button). I will attach a picture to help you, disregard the cats they are just the unpublished version of the data collection.

Hi,
I can think of 2 options:

  1. on button click, direct the user to a dynamic page. The dynamic page dataset on that page will have the info about the car that was clicked, and you can then use this data to pre-fill the input elements.

  2. on button click, save the relevant data using wix-storage, then pull it in the destination page and fill the input elements using the data you saved. Make sure to clear the data or override it so that you don’t ge unwanted leftovers…

Hi Ohad - can you tell me where this code is to be placed? How would this be integrated?

@jakeoswald12 you can add it within your page’s $w.onReady()

@ohad-laufer Thank you Ohad!!!

@ohad-laufer Do you know a programmer (yourself maybe?) who can help set this up for us? We have a similar issue and can’t make it work. Thx…

1 Like

@info89491 Yes, I can help you with this simple code.

@frank42028 What is it you are trying to do?

You may want to check out the WixArena - it’s a hub where you can look for Corvid (and other) experts for hire.

Hi @ohad-laufer

I am trying to do this exact same thing! I am a little not sure about how to input the code and where to input it?

Where does the info go etc? How does it populate etc?

@Ohad Laufer Is there an option to capture the URL parameters from the previous page instead of the current page? For example, prospect visits a product page, clicks through to lead form and submits. I want to know their previous page.

If so, does this have to be done with a custom form, or can I use a previously created WIX form so that I still receive email notifications upon form fill?

Old post reappearing, closed.
Add a new forum post if still need help.

Read Forum Guidelines too about tagging.
Use Tags Properly. You can only @ tag Wix Community Managers & Corvid Masters—NOT Wix employees.