Store URL in Contact Form Database

I’m looking to improve the contact form on our e-commerce site so that it includes the page URL that the enquiry was submitted from.

I can retrieve the page URL using “wixLocation.url” and then store this in a text box (See below). But, I can’t seem to link this to my custom contact form created with “User Input” fields. If I switch the text field to a user input field, the code below no longer works (“‘text’ does not exist on “contactUrl””). And if I use a simple text field, it isn’t then submitted to the database.

$w.onReady(function (){
let url = wixLocation.url
$w(“#contactUrl”).text = url
});

Any help would be greatly appreciated.

Hi,

Text input elements do not support the .text property.
You should change it to .value instead.

$w(" #t extInput").value = url;
$w(" #t extElement").text= url;

1 Like

Excellent, thank you Ido Inbar, it all works!