Hello,
Is it possible to update a field value on a form based with the value of another field or ifram on the form.
I am wanting to change the field age based on the result of the date of birth field. The result is currently being displayed within an iframe on the same form.
I have the following in the events section of a button
$( "#age" ).val(("#clientiframe").val);
If I use $( "#age" ).val('clientiframe'); then the age field contains the value clientframe
Thanks
Steve
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Field Values
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Field Values
Steve,
Have you seen this post?
Max.
there is a syntax error in your code (see here). Try this:stevem wrote:$( "#age" ).val(("#clientiframe").val);
If I use $( "#age" ).val('clientiframe'); then the age field contains the value clientframe
Code: Select all
$( "#age" ).val( $( "#clientiframe" ).val() );
Max.
-
- Posts: 8
- Joined: Tue Jun 24, 2014 12:59 pm
Re: Field Values
Hi Max,
I looked at the link to the external post and this works apart from the date I'm using is in the format dd-MMM-yyyy
I'm still trying to understand Java and so do not have a clue how to convert the code example so that it excepts the format above.
Any help with this would be appreciated.
Thanks
steve
I looked at the link to the external post and this works apart from the date I'm using is in the format dd-MMM-yyyy
I'm still trying to understand Java and so do not have a clue how to convert the code example so that it excepts the format above.
Any help with this would be appreciated.
Thanks
steve
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Field Values
Steve,
in the Events tab of your age field insert a new event:
- Event Name: onfocus
- Javascript: this code
Hope this helps,
Max
in the Events tab of your age field insert a new event:
- Event Name: onfocus
- Javascript: this code
Code: Select all
$( "#age" ).val(function() {
var d = new Date($( "#your-date-of-birth-field-name" ).val());
var dob = d.getFullYear();
var d = new Date();
var today = d.getFullYear();
return (isNaN(today - dob) ? 0 : (today - dob));
});
Max