Update field via JS before submitting data

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Steve Bone
New User
Posts: 11
Joined: Wed Jul 16, 2014 6:19 am
First Name: Steve
Last Name: Bone
Company Name: Kuehne + Nagel
Contact:

Update field via JS before submitting data

Post by Steve Bone »

I want to update a field via Javascript in my program just before submitting the information to the RPG program.
The updated field should contain the ID of the display field that last received input.

The problem is, when I use the onsubmit() event of the Record of the Displayfile, the javascript seems to be activated after the data was submitted. So with the next exfmt of my record, the field is empty again.
So instead of the onsubmit() event of the record, I use the onfocus() event of every field in the display now.
It works, but I do not like that I have to add this one line JS to everything in my Display.

Is there a way I can update the field with the ID of the Display field that currently has the focus without adding the JS to every onfocus() event on the screen?
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Update field via JS before submitting data

Post by Alex »

The event can be specified as a function name only. If used in this way, a response object containing all the values is passed to the specified function. The function can interrogate and even change the response values. The names in this object are stored as "FORMAT.FIELDNAME", where the format and the field name are both capitalized. So, in your external JavaScript file, you can create a function like this:

Code: Select all

function updateResponse(response) {
  response["MYSCREEN.MYDATA"] = "some information";
}
The onsubmit event would only have the function name:

Code: Select all

onsubmit: updateResponse
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests