Populating a field based on entry email address

By: Claire Wood | Asked: 01/20/2025
ForumsCategory: How-toPopulating a field based on entry email address
Claire Wood asked 1 month ago

I want to autocomplete a dropdown lookup field, based on the email address passed in the url, eg. https://www.the-domain.com/?pass_entry=xcbpr&email=test@abc.com

So the dropdown will have a list of entries from another form (Company, company email), but autocomplete/selected based on the domain name used in the email (so everything after the @).

So the lookup dropdown field on the form would be auto-selected as 'ABC', if they had a 'abc.com' email address.

Is anything like this at all possible?

2 Answers
Victor Font Staff answered 1 month ago

It's possible with custom code called in this hook: https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/

Claire Wood replied 1 month ago

Thanks, any pointers on how to get there? I've got stuck at getting the lookup to pull the correct company name based on the email to my form, let alone getting it to select this in the dropdown...

Victor Font Staff replied 1 month ago

With what you need to do, you have to create your own function. It's probably easiest to write your own SQL select.

Claire Wood replied 1 month ago

Hello, thanks, I have managed to sort the SQL query, but wondered if you could help with a JS function that would allow me to pre-select the dropdown.

Hidden field value="Company Name"

Dropdown value ="Company Name" selected

Any guidance?

Claire Wood replied 1 month ago

I have this so far, but not working:

$(function() {
$('#field_rqyn8').change(function(){
$('#field_b3291').val('' + this.value);
});
$('#field_b3291').change(function(){
$('#field_rqyn8').val(this.value.replace(''));
});
});

Bobby Clapp Staff answered 4 weeks ago

The code I'm looking at requires a "change" function to occur after the page loads. If the hidden value doesn't change on page load then the code would not function at all. Also I see two change functions doing different things. I'm guessing the change function needs to go away completely.

You'll have the $('#field_rqyn8').val() set to a variable to get the value if this is the hidden field.

myVal = $('#field_rqyn8').val();

Then load that variable into wherever you want it to go (without a change function requirement).

myVal = $('#field_rqyn8').val(); //gets the value of the hidden field
$('#field_b3291').val(myVal); //sets the value of another field to the collected value in the previous step
$('#field_rqyn8').val(myVal); //sets the value of another field to the collected value in the previous step

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right