Java Script in Adobeforms
Java Script in Adobeforms
/*
Where,
LV_DATA : variable to hold data
IM_TEST : context structure variable (Import parameter variable)
FIELDNAME : name of field in structure
*/
Retrieve context internal table data
var LV_DATA = xfa.resolveNode("$record.IM_TEST.DATA[" + INDX + "].FIELDNAME").value;
/*
Where,
INDX : index of table record. (start from zero).
LV_DATA : variable to hold data
IM_TEST : context table variable (Import parameter variable)
FIELDNAME : name of field in internal table
*/
OR if you are looping a table
var IMTEST = xfa.resolveNodes("$record.IM_TEST.DATA[*]");
var LV_DATA;
/*
Where,
INDX : index of table record. (start from zero).
LV_DATA : variable to hold data
IM_TEST : context table variable (Import parameter variable)
FIELDNAME : name of field in internal table
*/
Retrieve control (field) data
Manipulate (reference) fields in script for adobe forms
/*
Where,
this.name = name of a field. "use on initialize event
*/
Set dynamic reserve space of Caption
this.caption.reserve = "1in";
x = y % 2; //division remainder x = 1
Set floating points of field
this.rawValue = (this.rawValue).toFixed(3);
if (reg.test("Abcd")){
//expression passed
}
Set focus on filed
xfa.host.setFocus(this);
Populate Alert Message Box
xfa.host.messageBox("Helloo");
Set ToolTip of control
this.assist.toolTip.value = "toolTip text";
Set height of Sub-Form
var b = parseFloat(sfrmName.h) + 5;
if you are using DateTime adobe field you can directly give pattern to field.
Select DateTime Filed –> Go to property window –> click on Pattern button –> Select accordingly
Note:
Cancel Printing
data::prePrint - (JavaScript, client)
xfa.event.cancelAction = 1;
HTML Rich Text Rendering
var envelope = "<?xml version='1.0' encoding='UTF-8'?>" +
"<exData contentType='text/html' xmlns='http://www.xfa.org/schema/xfa-template/2.8/'" +
"><body xmlns='http://www.w3.org/1999/xhtml' xmlns:xfa='http://www.xfa.org/schema/xfa-
data/1.0/' " +
"xfa:APIVersion='Acroform:2.7.0.0' xfa:spec='2.1'>" +
"<p>"+ this.rawValue +"</p></body></exData>";
this.value.exData.loadXML(envelope,1,1);
in this dynamic world, client need all thing dynamic, changes according to the situation. and also
want to reduce all manual efforts.
As our adobe having many types of controls (fields), requirement may come like change this or that
according to this or that value. Here i want to deliver some javascript code and expenations for
looping all fields including master pages and body pages.
1. //formCalc
2. $.break.after = "contentArea" ; page break after current subform
3. ; can be processed only for subforms
I use empty subform (height = 0, no children), place it where I need a conditional break, make it
hidden, set top of next page for this special subform and write a script.
It works like this: when I need a page break, I use script to make the subform visible and only then
the pagebreaks happen.
A workaround, but works just fine.