Hi Julischka,
I hope this helps. This is the Javascript that I use in the click event of a button (called "Protect") that locks all the fields:
form1._1.Protect::click - (JavaScript, client)
var nButton = app.alert({
cMsg: "Warning after locking this form, you will not be able to unlock it. \n\nDo you want to lock this form?",
cTitle: "Assure HSC",
nIcon: 1, nType: 2
});
if ( nButton == 4 )
{
// 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 = "protected";
}
}
// save value of lock
Lock.rawValue = "1";
}
I have an invisible checkbox called "Lock". This hidden checkbox tracks if the form is locked or not. If the value is 0 then the form is unlocked and if the value is 1 the form is locked. You will see that the click event sets the value to 1 (locked).
Then in the ready event of the button I have the following Javascript:
form1._1.Protect::ready:layout - (JavaScript, client)
if (Lock.rawValue == "0")
{
// 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 = "open";
}
}
}
else
{
// 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 = "protected";
}
}
}
I have taken out some of the other script that I was using, so I hope that this still works for you.
Good luck,
Niall