Populate a field with value of a dropdown selection

Simple request… I thought! I have a dropdown field, and then a second field which I’d like to automatically display the value of whichever option the user just selected in the dropdown.

Apple | 1
Banana | 2

(Second field)
“2” appears when user selects “banana” in the dropdown.

I’m trying to learn about dynamic population and parameters and hooks, but every guide I can find involves too complex of scenarios. I’ve tried code from similar posts here but I’m pretty unfamiliar with PHP and for the life of me I can’t get any kind of field to dynamically populate. Can someone give me a push in the right direction?

Populate Anything is not in my budget unfortunately.

Hi Holly, to do this in the same form, you won’t be able to do this with PHP. That would be done with jQuery or JavaScript on the same page. You would need to create the custom script to copy the selection from one field to another.

There is a plugin available here which will take care of that without any code:

That plugin has a feature called “Live merge tags” which is what you need:
Live Merge Tags.
Add auto-updating merge tags anywhere inside your form (e.g. labels, descriptions, choices, values, HTML content).

1 Like