//To make the Field optional change the above statement to: this.parent.TextField1.mandatory = “warning”;
Author: brucrew96
Advanced Expanding Tables and Script Objects in Adobe LiveCycle ®
This tutorial demonstrates how Scripting Objects can be used to make more robust and better organized forms. Also, I demonstrate how to use check boxes to manipulate data rows in an expanding table.
Here is the code used in the Script Object and Check Boxes:
SO:
function addToTable(component, check_caption, check_uncheck)
{
var rowNum = component._Row1.count;
if (check_uncheck == 1) //check if click was on or off
{ //if on then add the row to the table
if (rowNum == 0)
{
component._Row1.addInstance();
component.Row1.Cell1.rawValue = check_caption;
}
else if (rowNum == 1) //if 1 and no value assign value
{
if (component.Row1.Cell1.rawValue == null) //check for available row
{
component.Row1.Cell1.rawValue = check_caption;
}
else //if 1 and value add row and assign value
{
component.Row1.instanceManager.addInstance();
component.resolveNode(“Row1[1]”).Cell1.rawValue = check_caption;
}
}
else if (rowNum > 1)
{
component.Row1.instanceManager.addInstance(); //count rows – if greater than 1 add row and assign value
component.resolveNode(“Row1[” + rowNum +”]”).Cell1.rawValue = check_caption;
}
}
else //if off then delete the row from the table
{
var rows = component.resolveNodes(“Row1[*]”);
var row = component;
for (var i=0; i<rows.length; i++) //find the correct row
{
var currentRow = rows.item(i);
if (currentRow.Cell1.rawValue == check_caption)
{
component._Row1.removeInstance(i);
}
}
}
}
Check Boxes:
SO.addToTable(this.parent.Table1, this.resolveNode(“caption.value.#text”).value, this.rawValue);
How to Populate a Dropdown Dynamically Using ODBC Data in LiveCycle ®
Simple ODBC Connections in Adobe LiveCycle ®
This tutorial demonstrates how to setup and connect to an Access 2010 Database using Adobe LiveCycle Forms through an ODBC connection.
Code used:
xfa.sourceSet.DataConnection.first(); (assuming the Data Connection name is “DataConnection”)
Check for null value in JavaScript
One of my YouTube subscribers recently posted a question related to “bound” data fields. This reminded me of how data bound fields are often susceptible to being populated with null values if the database is empty. Here is a little function I wrote to remedy this possibility:
function checkForNull(v_String)
{
var v_Space = ” “;
if (v_String == null)
{
return v_Space;
}
else
{
return v_String;
}
}
So, all we are saying here is that if the passed in value (v_String) equals null then return a value of ” ” (one space). If not, then just return whatever non-null value is there. This small function is used to “test” the string values of data that is passed from a database to a bound field.