Page 1 of 1
Setting a field value
Posted: Tue Jun 20, 2023 10:04 pm
by JohnR
I've done this before, but the mind is slipping.
When I exit a field I want to set another fields value to the value of the field I just exited.
Re: Setting a field value
Posted: Wed Jun 21, 2023 2:26 am
by wwonderfull
Still not clear to be honest. It might take events for sure. Provide a demo of your page if possible.
Re: Setting a field value
Posted: Wed Jun 21, 2023 5:44 am
by BaconFries
Previously asked see Pablos reply on the use of "Conditions"
viewtopic.php?p=463283#p463283
Re: Setting a field value
Posted: Wed Jun 21, 2023 1:16 pm
by JohnR
This is not necessarily a 'Condition' situation.
I always want field 2 to show the value entered in field1 after field 1 loses focus.
Re: Setting a field value
Posted: Wed Jun 21, 2023 1:55 pm
by BaconFries
So let's read this again...what your wanting is this for example user types username in input field1 and then onfocus input field2 username is inserted without retyping? If so see the following for information only.
https://www.plus2net.com/javascript_tut ... a-demo.php
https://jsfiddle.net/2maw8xo4/1/
https://jsfiddle.net/f84shzxu/
Re: Setting a field value
Posted: Wed Jun 21, 2023 4:22 pm
by wwonderfull
JohnR wrote: Wed Jun 21, 2023 1:16 pm
This is not necessarily a 'Condition' situation.
I always want field 2 to show the value entered in field1 after field 1 loses focus.
Thanks to @bacon I made a script for you : )
Code: Select all
<script>
document.getElementById("field1").addEventListener("blur", function() {
var x = document.getElementById("field1").value;
document.getElementById("field2").value = x;
});
</script>
Remember to change your input fields. Paste the code in the HTML tool and do not use any div.
Re: Setting a field value
Posted: Fri Jul 07, 2023 7:02 pm
by JohnR
Problem resolved - Thanks to all for your replies.
I put a Condition on Field 1 - On Change Calculate Field 2 = [Field 1].
Found that it DOES NOT work if Field 2 has a Floating Label.
Remove the Floating Label and all is right with the world.
Thanks Again!!!