calculate fields in Create/Update screen
calculate fields in Create/Update screen
agustin_garciaromero
Posts: 42Questions: 0Answers: 0
Hello,
I'm looking for a way to populate a readonly third field based on the changes on any of field one or two when user is either Creating or Updating a record.
The third field wil include some switch/case like rationale to determine its value.
Depending on whats easier or more secure, it can be done at the client or server side.
NOTE: There is no actual requirement for this field to be displayed to the user, though it could be more user friendly.
Thanks in advance
I'm looking for a way to populate a readonly third field based on the changes on any of field one or two when user is either Creating or Updating a record.
The third field wil include some switch/case like rationale to determine its value.
Depending on whats easier or more secure, it can be done at the client or server side.
NOTE: There is no actual requirement for this field to be displayed to the user, though it could be more user friendly.
Thanks in advance
This discussion has been closed.
Replies
However, to show the value to the user, what you'd need to do is bind an event to the input nodes in the form. You could use the new `node` method to do something like this:
[code]
$( 'input', editor.node( 'my_field' ) ).on( 'change keyup', function () {
editor.val( 'output_field', 'my-calculated-value' );
} );
[/code]
So what is happening there is that we are finding the 'input' element of the field with the name "my_field", assigning change and keyup events to it (you might want one, both or something else), and then when that event fires, assigning a value to a different Editor field which will be immediately updated for the user to see, and that value also submitted to the server.
Regards,
Allan
I didn't understand what the 'input' part of the snippet is for, but I made it work by inserting the following code:
$(editor.node( 'parent' )).on( 'change keyup', function () {
editor.set( 'child', 'TEST' );
} );
That works when 'child' is a TEXT field, but if I make it a SELECT, it doesn't respond to it.
Not sure:
a)If the 'input' part of your code has anything to do
b)If I need to dynamically change the nature (from TEXT to SELECT -and even if I could-) of the html objeect
c)If I need to use two 'child' fields and hide/show one or the other depending on user selection
In my case, the selection of Option A, may lead to a text entry option, while Option B may lead to a sub-select entry, C could be a select as well, etc.
Any comment on this one? Have someone done/required something like this?
Allan