Fill a field based on the equality between two fields

Hi there !
I am newly registered here. There seem to be some awesome contributors!

Here is my question :
I would like the value of a field (let’s call this field A) to be automatically changed to “OK” as soon as two other fields (B & C) values are equal. Fields A, B and C are in the same form, so the value of field A has to change without submitting the form.

I have tried many things from the comments here (, but I can’t get there yet.
May you please give me some help ?
Thank you

What kind of values do B and C accept? Is it a dropdown or freetext?

If it’s predictable, then you could do some conditional logic to show/hide ‘A’ and another field ‘D’.
Field ‘D’ would only ever have the value OK, you’d just show/hide it.

If B === value and C === value then show field D and hide field A.

Certainly you can also do this with custom javascript - listening for changes in field B and C and updating A when they are equal, but I’m guessing you want a point-and-click solution.

Thank you Simon :slight_smile:

B & C are numeric codes from “unique ID”, so unpredictable.
I need A to get a value in case B = C (and not just show) because this (A = OK ; A = OK or A = null) will give me a condition that I can use to make other fields visible.

Point-and-click would be the best, but if someone gave me a code to adapt and telle me were to put it, maybe I can be some kind of a wizard :sweat_smile:

Sorry I don’t know of a point and click way to achieve this. And the code is a bit too specific for me to spend time writing it for free. If you’re not even sure where to include the code then I think you’re a few steps too far from being a wizard haha. I recommend brushing up on some wordpress script enqueing and then you would google something like ‘javascript get field value’ and ‘javascript update field value’.

Sorry that’s as far I this train goes. Maybe someone has a point and click solution.

1 Like

I agree with everything @simonc said. But I’d like to suggest an alternative without having to write any code.

If it weren’t me, I’d add a few number fields and then on the third field enable a calculation. You can add your two values inside the calculation field and then use the third field for your conditional logic.

Here’s an article walking you through each step. Hope it helps.

Using Calculations

1 Like

I agree with everything @simonc said too : I am far below the minimum knowledge to code :grin:

@user5c0166073a6c48.6 … Will you believe me if I tell you this is exactly what I expected and was looking for for two days ? Thank you very much for this simple but perfect help !

I am definitly not a wizard, hopefully you were here :ok_hand:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.