Prefill based on URL

User 2087608 Photo


Registered User
15 posts

Good afternoon everyone,

Is there a way to get a field to prefill based on the URL for forms exported for manual setup? I put my JS file in the header of the contact.html that was generated, but it doesn't appear to be working as I had intended. Just wanted to know if this was even possible before I spent a whole day trying to make it work.

Thanks,
Krysten
User 187934 Photo


Senior Advisor
20,188 posts

Hi Krysten,
Take a look at this tip.
http://www.coffeecup.com/forums/web-for … post212728
If you don't want it hidden leave that part off.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2087608 Photo


Registered User
15 posts

Eric Rohloff wrote:
Hi Krysten,
Take a look at this tip.
http://www.coffeecup.com/forums/web-for … post212728
If you don't want it hidden leave that part off.


Great, thanks. I'll check it out.

EDIT: This script doesn't seem to do what I need it to. The script there provides a way to capture the entire URL, but I just want it to fill in based on part of the URL. Basically I need to be able to capture an item's ID from a previous page and have it fill in automatically based upon which button was clicked. I don't want the entire URL so that my client can easily distinguish about which item a customer is inquiring without requiring their customer to copy down the item ID and filling it in manually. I'll try adding the script I already have as an HTML element and see what happens.
User 187934 Photo


Senior Advisor
20,188 posts

Ok then you can use a URL variable.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2087608 Photo


Registered User
15 posts

Got it working with the following:

$(function () {
var prefill = document.location.search.replace('?', '');
prefill = prefill.split('&');
for (var i = 0; i < prefill.length; i++) {
var field = prefill[i].split("=");
$("input[name='" + field[0] + "'], select[name='" + field[0] + "']").val(field[1]);
}
});


It isn't allowing me to also do radio buttons, but that's really minor comparatively and not necessary for go-live. Thanks for your help.
User 187934 Photo


Senior Advisor
20,188 posts

What do you want to do to radio buttons?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.