Highlighted

Button to make all fields static and buttons be invisible

Avatar

Guest

14-02-2009

Hello,

i need help with one java script.

(my english is not the best one, because i´m a german member. I ask for pardon, when there are a lot of mistakes in my text. But i will try to give my best 🙂 )



I provided an offer formular.

Now i will build one button and this button must have some funktions when i push on it: (click event)



1. The whole formular with all fields on normal pages an masterpages must be static after pushing the button.You can´t write somthing anymor in this formular.



2. All my buttons are after pushing the button "invisible", from normal Pages and Masterpages.

(On my formular are 5 Buttons with names: Button1, Button2, Button3..."



3. It would be nice, when i push these Button and it opend me also a field where I can chose to save this document.

(like this java script:app.execMenuItem("SaveAs")



Could someone help me with a script which can make all these Things in a Click event?



About an answer I would be pleased much



Julischka

Replies

Highlighted

Avatar

Guest

14-02-2009

Hello again,



it´s easyer than i thougt. I mixt up all my single java script i have found in forums and now here it es.



I do not know, if it ist the best way, but it works perfekt 🙂



Here ist my skript for all Members, which need the same button.



Button1.presence="invisible";

Button2.presence="invisible";

xfa.resolveNode("#pageSet.Seite1.Button3").presence="invisible"



for (var i = 0; i < xfa.host.numPages; i++) {

var oFields = xfa.layout.pageContent(i, "field");

var nodesLength = oFields.length;

for (var j = 0; j < nodesLength; j++) {

var oItem = oFields.item(j); // Button1

if(oItem.name != "Button1") {

oItem.access = "readOnly";

}

}

}

app.execMenuItem("SaveAs");



p.s.: Button3 is on a Masterpage



Greetings

Julischka
Highlighted

Avatar

Guest

14-02-2009

Hello,



here I am back again. I was to early so happy, that it works.... 😞



Now is my problem, that this script works only on the page, where i have build the button.



Could someone say me please, what I must write also im my skript, that it works for the entire dynamic form? Inclusive Masterpage?



About an answer I would be pleased much

Greetings from Germany

Julischka
Highlighted

Niall_O_Donovan

14-02-2009

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
Highlighted

Avatar

Guest

14-02-2009

Dear Naill,



Thank you very much for your fast answer.

I tried to install your script, but it doesn´t work. I have chanched the Word Protect in "Schaltfläche1" <-- this ist my word for the button ,nothing happend. I don´t know if I must change more 😞

For me, it´s the first time, that I work with java script .

All what I have learned is from looking in forms which are in livecycle designer. I am looking to find the way out, how they have done that and after I try to make the same in my form.



In Germany you have no good books to learn about livecycle designer, an in all forums you get no answer for your questions. Therefore I try to get an answer in this forum, but it´s very hard, because my english is not so good.



But I dont give up 🙂



Maybe you ore someone else can send me a form, where I can look how you have done it?



My Mail adress is: hjuliett@aol.com



I wish you a nice evening and thank you very much again for your help



Julischka
Highlighted

Avatar

Guest

16-02-2009

Hello again,



knows none which script I must use to have all this functions?



It must be the same script to get the fields static, like a part of the script in the signature button.

There it works, that all pages (I have 8 dynamic Pages) incl. Masterpages (I have 4 Masterpages in my form) get static.



And in this script, there must be a function too, that all buttons from normal pages an Masterpages go "invisible".



Is there perhaps someone who could help me?



Please.....



If someone has a ready form with this function, I was very happy about sending it to me per mail, because my english ist not so good, that I understand complicated explainings here in the forum.



My Mailadress is: hjuliett@aol.com



Thank you for help

Julischa