Nov 18, 2022 12:53 PM
Hi! I’m trying to figure out how to ‘get’ the url of the page my form is on.
I’m deploying an embedded airtable form into hundreds of articles (We run a news site). I can not manually put the url in.
Most forms will tell you ‘where’ a user filled it out… is there an easy extension/way to get the url and submit it into a ‘single select’ or short text field?
Nov 18, 2022 01:09 PM
That is not possible with Airtable’s embedded forms. You would need to use JotForm’s embedded forms to do that. Check out this support article on JotForm’s site:
Nov 20, 2022 02:42 AM
Hmm, if you’ve got some web dev resources this could be relatively easy depending on how your site’s set up
You can prefill embedded forms, so you could potentially create a new field called “Source” or something, add it to your form and hide it, and then dynamically prefill it with the URL of the page it’s loading on?
Nov 21, 2022 01:51 PM
Hey Adam, this is a good point actually; I’m wondering if I can just make a simple HTML form and connect it to Airtable, skipping the Airtable form entirely? I have to look into the Airtable API a little more closely.
Nov 21, 2022 02:38 PM
What Adam is suggesting is much easier than creating a new HTML form that you would need to hook into the Airtable API. You also don’t want to be calling the Airtable API from a webpage as that would expose your API Key.
Instead, create a new field in your form to hold the name of the parent webpage. Then use query parameters for the url of the shared form to fill in that field and hide it. Each time you embed the form somewhere, change the query parameter to show where it is embedded. Thus you have only one form, but when people submit it, you see the webpage that you included in the query parameters.
Nov 22, 2022 03:03 AM
@kuovonne explained it much clearer than I could!
Nov 22, 2022 01:37 PM
Thank you for this!
Basically, you and he are suggesting I can just use my jQuery code to get the url & put it in the embedded form, so I don’t have to recode my own form in HTML?
Nov 22, 2022 08:50 PM
Yeap, you hit the nail on the head!
Dec 09, 2022 11:43 AM
Sadly, I've hit another snag! the form input IDs are dynamically generated it seems so I can't use my javascript, which targets the element by an ID.
var urlField = document.getElementById("WHAT GOES HERE?").value;
var aflinkfill = document.URL;
urlField.value = aflinkfill;