JavaScript の例

この節の例では、JavaScript スクリプティング環境でサポートしているプロパティおよびメソッドを示します。

オブジェクトの参照

次の例では、オブジェクトの参照方法をいくつか示します。

オブジェクトの特定のインスタンスにアクセスするときは、スクリプトがあるオブジェクトのオカレンス番号に注意してください。スクリプトはスクリプトがあるオブジェクトと同じオカレンス番号を持つオブジェクトを返します。例えば、同じ名前の 3 つのボタン(Button1[0]、Button1[1]、および Button1[2])と同じ名前の 3 つのテキストフィールド (TF1[0]、TF1[1]、および TF1[2])があるとします。Button1[2] のスクリプトが xfa.host.messageBox(TF1.rawValue) である場合、結果は TF1[0].rawValue ではなく、TF1[2].rawValue です。

スクリプト

テキストフィールドの最初のインスタンスへのアクセス

// Access a sibling field using the field name. 
// Access the first instance of TextField1.  
TextField1.rawValue = "Hello";

テキストフィールドの最初のインスタンスへのアクセス

// Access the first instance of TextField1. When scripting with JavaScript, use 
// xfa.resolveNode to start the search at the top and move down the form  
// hierarchy. 
xfa.resolveNode("TextField1").rawValue = "Hello"; 
xfa.resolveNode("TextField1[0]").rawValue = "Hello";

アクセッサーを持つフィールドへのアクセス

// When scripting with JavaScript, use the resolveNode() method to access a 
// field with a SOM expression that contains a # or [] operator. When searching 
// with this.resolveNode, the search starts at the current object and moves up 
// the form hierarchy.  
this.resolveNode("Subform2[1].NumericField4").rawValue = 25;

インデックス番号を持つサブフォームへのアクセス

// Access a subform with an index number. When using xfa.resolveNode,the search 
// starts at the top of the form hierarchy and moves down.  
var nIndex = 2; 
var sSOM = "Subform2[" + nIndex + "]"; 
var oSubform = xfa.resolveNode(sSOM); 
oSubform.NumericField4.rawValue = "25";

フィールドプロパティへのアクセス

// Access a field property using a property name and value. 
// Change the field properties of a specific subform. 
// Use the [] operator to access an object's property. 
var sProperty = "access"; 
var sValue = "readOnly"; 
 
// First, get the subform nodes. 
    var oNodes = Subform2.nodes; 
    var nNodesLength = oNodes.length; 
 
    // Loop through the subform's nodes and look for fields. 
    for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount ++) { 
        // Set the field property. 
        if (oNodes.item(nNodeCount).className == "field") { 
            oNodes.item(nNodeCount)[sProperty] = sValue; 
        } 
    }

ドキュメントのテキストフィールドのカウント

// Count the number of text fields in a document.  
// Get the field containers from each page. 
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) { 
 
    var oFields = xfa.layout.pageContent(nPageCount, "field"); 
    var nNodesLength = oFields.length; 
    var nCount = 0; 
 
    for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
 
        if (oFields.item(nNodeCount).ui.oneOfChild.className == "textEdit") { 
            nCount++; 
        } 
    } 
    TextField1.rawValue = nCount; 
}

一部のオブジェクト名を使用してのフィールドへのアクセス

// Access fields using partial object names. 
// Get the field containers from each page. 
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) { 
 
    var oFields = xfa.layout.pageContent(nPageCount, "field"); 
    var nNodesLength = oFields.length; 
 
    for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
        if (oFields.item(nNodeCount).name.substr(0,2) == "Te") { 
            xfa.host.messageBox(oFields.item(nNodeCount).name); 
        } 
    } 
}

選択リストの値へのアクセス

// Use the newText or prevText property to access the choice list value before 
// or after the value changed. 
// Trigger the script on a change event. 
TextField1.rawValue = xfa.event.prevText; 
TextField2.rawValue = xfa.event.newText;

サブフォームの 1 つのフィールドへのアクセス

// Access a field nested inside a sibling subform by prefixing the field name 
// with its parent name. 
Subform2.TextField3.rawValue = "Hello";

サブフォームの複数のフィールドへのアクセス

// Access the first-level fields nested inside a subform. 
Subform1.resoveNodes("#field[*]")

各ページのフィールドの取得

// Get the field containers from each page. 
for (var i = 0; i < xfa.host.numPages; i++) { 
 
var oFields = xfa.layout.pageContent(i, "field"); 
var nodesLength = oFields.length; 
 
// Set the access type. 
for (var j = 0; j < nodesLength; j++) { 
 
        var oItem = oFields.item(j); 
 
        if (oItem != this) { 
 
        oItem.access = "readOnly"; 
        } 
    } 
}

データモデルのノードの作成

この例では、新規データモデルノードの作成またはコピー方法を示します。

スクリプト

データノードの作成

// Display the number of child nodes under the rootNode (xfa.record). 
// rootNode is the data file's root node. 
xfa.host.messageBox("Initial number of nodes under rootNode: " + xfa.record.nodes.length); 
// Create a node of type dataGroup. 
var oGroupNode = xfa.datasets.createNode("dataGroup", "NewGroupNode"); 
 
// Append the data group node to an existing data model node. 
xfa.record.nodes.append(oGroupNode); 
 
// Display the number of child nodes under rootNode. 
xfa.host.messageBox("Number of nodes under rootNode after first append: " + xfa.record.nodes.length); 
 
// Create a node of type dataValue. 
var oValueNode = xfa.datasets.createNode("dataValue", "NewValueNode"); 
 
// Set the value of the new data value node. 
oValueNode.value = "The item value"; 
 
// Append the data value node to the data group created above. 
xfa.record.NewGroupNode.nodes.append(oValueNode); 
 
// Get the value from the data model. 
TextField1.rawValue = xfa.record.NewGroupNode.NewValueNode.value; 
 
// Append a cloned data group node. 
xfa.record.nodes.append(xfa.record.NewGroupNode.clone(1)); 
 
// Display the number of child nodes under rootNode. 
xfa.host.messageBox("Number of nodes under rootNode after appending clone: " + xfa.record.nodes.length); 
 
// Set the value of the new data value node. 
xfa.resolveNode("xfa.record.NewGroupNode[1].NewValueNode").value = "The clone value"; 
 
// Get the value of the cloned data value node. 
TextField2.rawValue = xfa.resolveNode("xfa.record.NewGroupNode[1].NewValueNode").value; 
 
// Remove the cloned data group from the node list. 
var oRemoveNode = xfa.resolveNode("xfa.record.NewGroupNode[1]"); 
xfa.record.nodes.remove(oRemoveNode); 
 
// Display the number of child nodes under rootNode. 
xfa.host.messageBox("Number of nodes under rootNode once clone node removed: " + xfa.record.nodes.length);

サブフォームのインスタンスの操作

次の例では、実行時にサブフォームのインスタンスを追加または削除する方法をいくつか説明します。

インスタンスマネージャーを使用して、固定レイアウトを含むフォームのページを操作します。それぞれのページは 1 つのサブフォームです。そのため、サブフォームの追加または削除は 1 ページの追加または削除に似ています。ただし、実行時は固定レイアウトを含むフォームのレイアウトを変更することはできません。form:ready イベントではインスタンスを追加したり、削除したりすることができます。ただし、click など実行時イベントに対するスクリプトである場合は、何も実行されません。

スクリプト

インスタンスマネージャーを呼び出してインスタンスを追加

// Add an instance of a subform by using the underscore syntax to invoke the 
// instance manager directly. 
// Forms rendered in a web browser do not support the underscore syntax. 
// However, the underscore syntax is supported if the script runs at the 
// server. 
_Subform2.addInstance(1);

instanceManager プロパティを呼び出してインスタンスを追加

// Add an instance of a subform by invoking the instanceManager property. Be 
// careful to ensure that adding a subform will not violate the max occur 
// value. 
Subform2.instanceManager.addInstance(1);

インスタンスの削除

// Remove an instance of a subform. Set the min occur value only if removing an 
// instance will violate it. For example, set the min occur to 0 if you want to 
// remove the last, or the only, instance of a subform.  
// Forms rendered in a web browser do not support the underscore syntax. 
// However, the underscore syntax is supported if the script runs at the 
// server.  
Subform2.occur.min = "0"; 
_Subform2.removeInstance(0);

親サブフォームの削除

// Remove the parent subform. 
parent.occur.min = "0"; 
parent.instanceManager.removeInstance(parent.index);

インスタンス数の設定

// Set the number of instances of a subform. 
var oSubform = xfa.resolveNode("Subform2"); 
oSubform.instanceManager.setInstances(5);

新規サブフォームインスタンスの挿入

// Insert a new subform instance. This script will not work with a static form. 
// The script is invoked by a button, named Insert Subform, that is nested 
// inside a repeating subform. The new subform is inserted below the current 
// subform.  
var oSubform = this.resolveNode("Subform2"); 
var oNewInstance = oSubform.instanceManager.addInstance(1); 
var nIndexFrom = oNewInstance.index; 
var nIndexTo = this.parent.index + 1; 
// Invoke the instanceManager to insert the subform below the current one. 
oSubform.instanceManager.moveInstance(nIndexFrom, nIndexTo);

サブフォームの追加および削除

// Invoke the instance manager to add and remove the comments subform. 
if (fComments.value == "0") { 
// In this example, fComments is a document variable used as a flag. 
// The fComments variable equals 1 when the comments subform is displayed. 
_comments.setInstance(1);  
// Add the comments subform. Change the button's caption. 
this.resolveNode("caption.value.#text").value = "Clear Comments";  
// Set the flag value. 
fComments.value = "1";  
} 
else { 
// Remove the comments subform. 
_comments.setInstance(0);  
// Change the button's caption. 
this.resolveNode("caption.value.#text").value = "Add Comments";  
// Reset the flag value. 
fComments.value = "0"; 
}

オブジェクト値の取得または設定

次の例では、オブジェクトの値の取得または設定方法をいくつか説明します。

使用例

プロパティ

formattedValue

rawValue

value

スクリプト

rawValue の使用

// Use the rawValue property to set and get a field's raw value. 
TextField1.rawValue = "K1V1W3"; // Set the field's raw value. 
TextField2.rawValue = TextField1.rawValue // Get the field's raw value. 

値の使用

// Use the value property to set and get the field's raw value. 
TextField1.rawValue = "k1V1W3"; 
TextField2.rawValue = TextField1.value.oneOfChild.value

formattedValue の使用

// Use the formattedValue property to set and get the field's formatted value. 
// Use the value property to set and get an object's value (picture). 
TextField1.rawValue = "K1V1W3"; // Set the field's raw value. 
TextField1.format.picture.value = "A9A 9A9"; // Set the field's display picture format. 
TextField2.rawValue = TextField1.formattedValue; // Get the field's formatted value. 

データオブジェクトの値の設定

// Use the value property to set and get a data object's value. 
// In this script, groupNode is a data group and addressL1 is a data value in 
// the data file. 
TextField1.rawValue = xfa.record.groupNode.address.line1.value;

ドキュメント変数の値の設定

// Use the value property to set and get the document variable's value. 
TextField1.rawValue = docVar.value;

ページ番号とページ数の使用

次の例では、ページ番号とページ数を使用するホストモデルおよびレイアウトモデルの使用方法をいくつか示します。

ページ番号およびページ数を使用するプロパティとメソッドは、ホストモデルとレイアウトモデルではいくつか異なります。プロパティとメソッドは、スクリプトの実行内容と実行する時に応じて使用する必要があります。

ホストプロパティおよびメソッドの多くは、サーバーでは使用できません。実行時にページ番号を設定または取得するには、ホストプロパティおよびメソッドを使用します。

ページ番号を設定するレイアウトモデルはありません。layout:ready で現在のページを取得したり、クライアントでフォームを開いたときにページの下にページ番号を表示して、ページ番号を確認できるようにするには、レイアウトモデルを使用します。

スクリプト

ページ番号の取得

// Use the page layout methods to get the current page number. 
TextField1.rawValue = xfa.layout.page(this); // 1-based. 
TextField2.rawValue = xfa.layout.absPage(this); // 0-based. 

pageCount メソッドによるページ数の取得

// Use the layout pageCount methods to get the number of pages in a document. 
TextField1.rawValue = xfa.layout.pageCount(); // Get the logical number of pages. 
TextField2.rawValue = xfa.layout.absPageCount(); // Get the physical number of pages. 

ページ編集の形式設定

// Use the layout page and pageCount methods to format the pagination. 
TextField1.rawValue = "Page " + xfa.layout.page(this) + " of " + xfa.layout.pageCount();

現在のページ番号の取得と設定

// Use the host currentPage property to get and set the current page number at // run time. 
// This script cannot be used during a layout:ready, form:ready, or initialize // event. However, it will work if the script is on a button. 
xfa.host.currentPage = 1; // Go to page 2 (0-based). 

numPages プロパティによるページ数の取得

// Use the host numPages property to get the number of pages in a document. 
TextField1.rawValue = xfa.host.numPages; // Get the number of pages. 

ドキュメントの下に移動

// Use the host pageDown() method to navigate through a document. 
xfa.host.pageDown(); // Go to the next page. 

ドキュメントの上に移動

// Use the host pageUp() method to navigate through a document. 
xfa.host.pageUp(); // Go to the previous page. 

データ値の連結

この例では、アドレスブロックにデータ値を連結し、空白行がないことを確認する方法を示します。

使用例

プロパティ

メソッド

multiLine

oneOfChild

rawValue

value

record

スクリプト

データ値の連結

// Get the values from the data model. 
var sName = xfa.record.groupNode.address.line1.value; 
var sPostbox = xfa.record.groupNode.address.line2.value; 
var sStreet = xfa.record.groupNode.address.line3.value; 
var sCity = xfa.record.groupNode.address.line4.value; 
var sRegion = xfa.record.groupNode.address.line5.value; 
var sCountry = xfa.record.groupNode.address.line6.value; 
var sPostcode = xfa.record.groupNode.address.line7.value; 
var addressArray = new Array(sName,sPostbox,sStreet,sCity,sRegion,sCountry,sPostcode); 
 
var sAddressBlock = ""; 
 
// Don't display the postbox if the value is not provided. 
if (addressArray[1] == null) { 
        sAddressBlock = addressArray[0] + "\n" + addressArray[2] + "\n" + addressArray[3] + "\n"; 
} else { 
        sAddressBlock = addressArray[0] + "\n" + addressArray[1] + "\n" + addressArray[3] + "\n"; 
} 
 
// Do not display the region if the value is not provided.  
if (addressArray[4] == null) { 
sAddressBlock = sAddressBlock + addressArray[5] + " " + addressArray[6]; 
} else { 
sAddressBlock = sAddressBlock + addressArray[4] + ", " + addressArray[5] + " " + addressArray[6]; 
} 
TextField2.rawValue = sAddressBlock; 
// Make sure the field is set to display a multiple line value. To set the 
// multiLine property programmatically, add the following line: 
        TextField2.ui.oneOfChild.multiLine = "1";

合計の計算

この例は、合計を計算する方法を示します。

使用例

プロパティ

メソッド

length

rawValue

resolveNodes

スクリプト

合計の計算

// Access a field in a repeating subform by looping through the node list. 
var oFields = xfa.resolveNodes("Subform2[*].NumericField4"); 
var nNodesLength = oFields.length; 
var nSum = 0; 
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
    nSum += oFields.item(nNodeCount).rawValue; 
} 
TextField1.rawValue = nSum;

背景色の変更

次の例では、サブフォームまたはフィールドの背景色を変更する方法を示します。

編集可能なレイアウトを含むフォームでは、実行時にキャプション、フィールド領域を含むフィールド全体の背景色を変更できます。ただし、固定レイアウトを含むフォームでは、実行時には、フィールド領域の背景色の変更のみが可能です。

スクリプト

サブフォームの背景色の変更

// Alternate the background color of a repeating subform. 
var oNodes = xfa.resolveNodes("Subform2[*]"); 
var nNodesLength = oNodes.length; 
 
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
    if (oNodes.item(nNodeCount).index%2 != 0) { 
        oNodes.item(nNodeCount).border.fill.color.value = "200,200,250"; 
    } else { 
        oNodes.item(nNodeCount).border.fill.color.value = "200,150,250"; 
    } 
}

フィールドの背景色の変更

// Alternate the background color of the NumericField4 field. 
// Before running this script, set a background color or set the 
// border.fill.presence property to visible. 
var oNodes = xfa.resolveNodes("Subform2[*]"); 
var nNodesLength = oNodes.length; 
var sFillColor; 
 
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
 
    if (oNodes.item(nNodeCount).index%2 != 0) { 
        sFillColor = "200,200,250"; 
 
    } else { 
        sFillColor = "200,150,250"; 
 
    } 
    oNodes.item(nNodeCount).NumericField4.fillColor = sFillColor; 
}

サブフォームの行の背景色の変更

// Reset the fields of the current subform. 
var dString = "xfa.form.form1.dtls[" + this.parent.index + "]"; 
var oDetails = xfa.form.resolveNode(dString); 
var sDtlFields; 
 
// Build the string of field names to reset. 
for (var i = 0; i < oDetails.nodes.length; i++) { 
    sDtlFields = sDtlFields + "," + dString + "." + oDetails.nodes.item(i).name; 
} 
// Pass the string variable as a parameter. 
xfa.host.resetData(sDtlFields); OR  
// Alternate the background color of the repeating rows. 
if (this.index%2 != 0)  this.border.fill.color.value = "255,255,255"; else  this.border.fill.color.value = "201,201,146";

コンボボックスの入力

次の例では、コンボボックスにリスト項目を追加または削除する方法をいくつか示します。

実行時にコンボボックスに入力する前に項目リストを保存してください。保存しない場合は、項目が失われます。データに保存されるのは値のみです。

スクリプト

Web サービスからのコンボボックスの入力

// Populate the drop-down list with values from a web service. 
// The web service used in this example is fictional.  
SOAP.wireDump = false; 
var oListURL = "http://www.webservice.net/wsdl/query.wsdl"; 
var e; 
try 
{ 
    xfa.host.messageBox("Starting list retrieval."); 
     
    var service = SOAP.connect(oListURL); 
 
    if(typeof service != "object") { 
        xfa.host.messageBox("Couldn't get List object."); 
    } 
    if(service.getAllServiceNames == "undefined") { 
        xfa.host.messageBox("Couldn't get getAllServiceNames Call."); 
        } 
     
    // Start the query 
    var oItems = service.getAllServiceNames(); 
    if(oItems == null) { 
        xfa.host.messageBox("List empty."); 
        } 
var nCount = 0; 
    var nLimit = 10; 
     
    for(var nItemCount in oItems)  
    { 
        for(var nItemNode in oItems[nItemCount]) 
        { 
            if (nItemNode == "name") 
                DropDownList1.addItem(oItems[nItemCount][nItemNode]); 
        } 
        if (++nCount >= nLimit) 
            break; 
    } 
} 
catch(e) 
{ 
    xfa.host.messageBox("Problem with list Call: " + e); 
}

コンボボックスのクリア

// Clear the items in a drop-down list. 
DropDownList1.clearItems();

データファイルからのコンボボックスの入力

// Populate the drop-down list with values from a data file. 
var oItems = xfa.resolveNode("xfa.record.groupNode.list"); 
var nItemsLength = oItems.nodes.length; 
 
for (var nItemCount = 0; nItemCount < nItemsLength; nItemCount++) { 
    DropDownList1.addItem(oItems.nodes.item(nItemCount).value); 
} 
DropDownList1.rawValue = "Second item in list";

コンボボックスの値を他のフィールドに保存

// Access the items in a drop-down list box and save their values in a separate 
// field. 
var oItems = xfa.resolveNode("DropDownList1.#items"); 
var nItemsLength = oItems.nodes.length; 
 
for (nItemCount = 0; nItemCount < nItemsLength; nItemCount++){ 
 
    if (TextField2.rawValue == null) { 
        TextField2.rawValue = oItems.nodes.item(nItemCount).value; 
    } else { 
        TextField2.rawValue = TextField2.rawValue + "\n" + oItems.nodes.item(nItemCount).value; 
    } 
}

newText プロパティまたは prevText プロパティを使用してコンボボックスの値にアクセス

// Use the newText or prevText properties to access a drop-down list value 
// before or after the value changes. 
// Execute the script on a change event. 
TextField1.rawValue = xfa.event.prevText; 
TextField2.rawValue = xfa.event.newText;

フォームの保存

次の例では、フォームからデータを書き出したり、フォームを保存したりする方法を示します。

使用例

プロパティ

メソッド

target

exportData

スクリプト

ファイル名を指定しないフォームデータの書き出し

// Export a form's data without specifying a file name. The end user is 
// prompted to provide the file name. 
xfa.host.exportData();      // Will generate data in XDP format. 
xfa.host.exportData("", 0); // Will generate data in XML format. 

ファイル名を使用してのフォームデータの書き出し

// If you specify a file name, the script must run on a certified form. 
xfa.host.exportData("filename.xdp");    // Will generate data in XDP format. 
xfa.host.exportData("filename.xml", 0); // Will generate data in XML format. 

フォームの保存

// Saving the form is done at the application level, so you need to invoke the 
// Acrobat app model. 
App.executeMenuItem("SaveAs"); // The end user will be prompted to specify a 
// file name.  
// However, you must save the form silently if the form needs to be certified 
// and the certificate must be trusted for privileged JavaScript. 
var mydoc = event.target; 
mydoc.saveAs();

オブジェクトの表示または非表示の切り替え

この例では、オブジェクトの表示と非表示を切り替える方法について説明します。「印刷」ボタンが非表示の場合、ユーザーはフォームを印刷することはできません。

prePrint イベントは、印刷用にフォームがレンダリングされる直前にトリガーされます。同様に、postPrint イベントはフォームが印刷された直後にトリガーされます。

使用例

プロパティ

presence

relevant

スクリプト

フィールドを表示または非表示に設定

// If a field is visible, make it invisible and vice versa. 
if(Field1.presence == "visible") 
{ 
    Field1.presence = "invisible"; 
} 
else 
{ 
    Field1.presence = "visible"; 
}

ボタンを表示するけれども印刷不可に設定

// Set a button to be visible but non-printing at design time.  
Button1.relevant="-print"

ラジオボタンおよびチェックボックスの使用

次の例では、ラジオボタンとチェックボックスを選択およびクリアする方法について説明します。

使用例

プロパティ

メソッド

rawValue

messageBox

resolveNodes

スクリプト

ラジオボタンの選択

// Select the first radio button. 
RadioButtonList.rawValue = '1'; 
xfa.host.messageBox('Value of RadioButtonList: ' + RadioButtonList.rawValue); 
 
// Select the second radio button. 
RadioButtonList.rawValue = '2'; 
xfa.host.messageBox('Value of RadioButtonList: ' + RadioButtonList.rawValue);

ラジオボタンのアクセス

// Access the radio buttons. 
RadioButtonList.resolveNodes("#field[*]")

ラジオボタンのクリア

// Clear a RadioButtonList value. Any invalid value will clear the list. 
RadioButtonList.rawValue = '3'; 
xfa.host.messageBox('Value of RadioButtonList: ' + RadioButtonList.rawValue);

チェックボックスの選択

// Select a check box. 
CheckBox1.rawValue = 1; 
xfa.host.messageBox('Value of checkbox: ' + CheckBox1.rawValue);

チェックボックスの選択解除

// Deselect a check box. 
CheckBox1.rawValue = 0; 
xfa.host.messageBox('Value of checkbox: ' + CheckBox1.rawValue);

フォーム変更の判定

この例では、フォームが変更されたことを判定する方法を示します。

使用例

プロパティ

メソッド

rawValue

messageBox

saveXML

スクリプト

フォーム変更の判定

// Save a copy of the original XML file. 
var sOriginalXML = xfa.data.saveXML(); 
 
// Change the form data. 
TextField1.rawValue = "changed"; 
 
// Determine whether the form data has changed. 
if(sOriginalXML == xfa.data.saveXML()) 
{ 
    xfa.host.messageBox("Form has not changed."); 
} 
else 
{ 
        xfa.host.messageBox("Form has changed."); 
}

すべてのフォームフィールドの無効化

この例では、フォームのすべてのフィールドを無効にする方法を示します。

使用例

プロパティ

メソッド

access

layout

length

numPages

item

pageContent

pageCount

スクリプト

すべてのフォームフィールドの無効化

// Get the field containers from each page. 
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) { 
var oFields = xfa.layout.pageContent(nPageCount, "field"); 
var nNodesLength = oFields.length; 
 
// Set the field property. 
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) { 
oFields.item(nNodeCount).access = "readOnly"; 
} 
}