Expand my Community achievements bar.

SOLVED

Copy content of text field to another text field

Avatar

Level 2

Hi everybody,

I'm new in the LiveCycle world. Therefore please excuse these stupid (?) questions.

I try to create a form. This form has three pages at the moment. On the first page the user has to fill in a service number.

How can display this service number on the following pages?

I read something about JavaScript and FormCalc. Is there a manual for beginner? A manual or a good how to would be great because I have more question and don't wont to bother the forum that much. e.g. is ist possible to hide a "Kontrollkästchen" (english control box ?) when another Kontrollkästchen is not checked? Something like a "IF box A not true THEN hide box B".

Regards

Dennis

Thorlabs HL

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Dennis,

Your question is very valid; you know what you want the programme to achieve, it is just getting it to do it.

You can do this without scripting. If you copy the field to each page, you can set the binding to "global". This means that all fields with that object name will have the same value.

04-05-2009 16-17-03.png

If the object is going to be in the same place on each page, you could put the object on the Master Page.

Some resources are in this tread: http://forums.adobe.com/thread/427826?tstart=0

Also have a look at the help file for setting up your workspace...

04-05-2009 16-22-15.png

Good luck,

Niall

View solution in original post

17 Replies

Avatar

Correct answer by
Level 10

Hi Dennis,

Your question is very valid; you know what you want the programme to achieve, it is just getting it to do it.

You can do this without scripting. If you copy the field to each page, you can set the binding to "global". This means that all fields with that object name will have the same value.

04-05-2009 16-17-03.png

If the object is going to be in the same place on each page, you could put the object on the Master Page.

Some resources are in this tread: http://forums.adobe.com/thread/427826?tstart=0

Also have a look at the help file for setting up your workspace...

04-05-2009 16-22-15.png

Good luck,

Niall

Avatar

Level 4

Hallo Thorblabs

Also, am besten bennenst du deine Seiten. Dann kannst du einfacher auf die jeweiligen Objekte zugreifen.

f.ex. wenn du Seite1 "Seite1" nennst wäre es eventuell:

this.rawValue = Seite1.Textfeld1.rawValue

im Calculate Event, Javascript, im Feld in das du den Wert von Textfeld1 reinkopiert haben willst.

Solltest du mit Subforms arbeiten, kann das auch längere bezeichnungen haben. Die jeweilige Bezeichnung eines Feldes findest du in dessen Scriptkästchen. Sollten diverse Felder allerdings gar nicht benannt sein (wie oben beispielsweise Seite 1), hab ich dabei schon ein paar mal Probleme gehabt.

Natürlich kannst du das ganze genauso auch über Globale Bindungen oder die Masterpage handhaben. Nialls Vorschlag wäre in dem Fall, dass du diesen Wert auf keine Weise verändern willst um einiges besser. Trotzdem habe ich das oben einmal stehn gelassen, da es den allgemeinen Zugriff auf Felder von anderen Seiten für Berechnungen erklärt erklärt.

Hier ist ein Script, Formcalc, in dem ein Kästchen versteckt wird dieses mal in Formcalc (geht natürlich auch in javascript):

if (NULL == 1) then this.presence ="hidden" else this.presence = "visible" endif

Wir helfen dir im Forum gern ;D und ich weiß auch nicht 100% ob es ein Tutorial gibt, aber ein paar Seiten dieses Forums durchblättern hilft schon bei den meisten Fragen ^^

Niall... again you've been faster and your solution was easier ^^

But it seems as if I could talk in my mothertongue here ;D

Avatar

Level 10

Danke Ocen12,

Ihre Lösung ist einfacher zu verstehen.

Ich spreche nicht deutsch, meine Tochter helfe mir.

viel Glueck,

Niall  (und Alice)    ;-)

Avatar

Level 2

Many thanks to both of you. Both answer are very helpful for me. I will go with Nialls "global function bindung" because it is easier. (After knowing how to do it ... oh boy it really is simple.) But Ocen12's solution is also very nice because it is a way to modify the value before displaying it.

Thanks again. Beside a solution for my problem you also gave me a first impression how JavaScript is working. Bacause of both of you I can produce first results today. In the next days I will scan thru the forum to learn and understand the basics.

@ocen12: Bitte benutz auch in Zukunft deine "mothertongue". Es tut richtig gut nicht jedesmal mit einem Wörterbuch arbeiten zu müssen.

Problem solved; user happy.

Dennis

Thorlabs HL

Avatar

Level 2

Hi Oce12,

muß da doch noch mal nachhaken...

Ich habe dieses Optionsfeld. Das hat einen Gruppenname und jede Option einen einzelnen Namen. Wie komme ich da an die Werte? (siehe unten)

Irgendwie mache ich einen Gedankenfehler, da deine if-Anweisung irgendwie nicht will. Muß ich den Namen der Gruppierung "weiteresVorgehen" mit angeben? Kann ich direkt "Vorgehen" abfragen mit Werten 0,1,2,3,... oder muß ich die Optionen einzeln auf 0 (false) oder 1 (true) prüfen?

Und baut man das Script eher bei den Optionen die prüfe ein oder bei dem davon abhängigen Kontrollkästchen?

Beides ist theoretisch möglich. Was ist sinnvoller? Was ist "gutes/sauberes Programmieren"?

Ich würde es unter "Calculate" ablegen. Liege ich damit richtig?

Dennis

Thorlabs HL

Avatar

Level 4

Was genau passiert bei deinem Script?

Hmm... ich bin eigentlich auch nur ein Amateur was programmieren betrifft ^^ meist auch ziehmlich unsauber und nur aufs Ziel fixiert.

Ich hab in eine Optionsfeldliste mit 3 Optionsfeldern ins "MouseUp" Event des jeweiligen Optionsfeldes folgendes geschrieben (Javascript dieses mal):

if (this.rawValue == "1") {Dezimalfeld1.presence = "visible";}


if (this.rawValue == "2") {Dezimalfeld1.presence = "invisible"; Dezimalfeld1.rawValue = null;}


if (this.rawValue == "3") {Dezimalfeld1.presence = "invisible"; Dezimalfeld1.rawValue = null;}

Das null steht dafür, dass alle bereits eingetragenen Werte gelöscht werden. Also quasi ein leeres Feld.


Funktioniert soweit... sollte es bei dir nicht ganz unsichtbar werden (dh. nur schreibgeschützt oder ähnliches), schreib mir mal deine Mail Adresse auf, dann schick ich dir ein leeres Formular in dem es funktioniert...

Bei mir ist's so, dass ich bei meiner primären Version von LCD da auch ein Problem habe (glaub es ist nen Versionsproblem oder etwas ähnliches). Deshalb nehme ich immer ein leeres anderes Formular und kopiere mir da alle Felder rein (natürlich Seitenweise ^^). Dann funktioniert es.

(Einige speichern es auch als dynamisches Formular... aber bei mir hilft das nichts... und das Formular bei dem es funktioniert ist ebenfalls nicht dynamisch... etwas verwirrend aber hauptsache das Endprodukt stimmt ^^ )

MfG

Lisa

PS.: Niall: be proud of your daughter her German is very nice and polite... and Germans know that our language is haaard to learn ;D

Avatar

Level 2

Bei mir tut sich nichts. Es ist zum Haareraufen. Ich habe immer das Gefühl ich trage das Script im falschen Feld ein. Initialize, Enter, Exit, Calculate. Ich habe noch nicht raus, wer wann aufgerufen wird. Aber es passiert einfach nichts. Wenn ich das Script in Calculate eintrage erhalte ich eine Fehlermeldung, das ich das Feld nicht bearbeiten darf.

Ich habe etwas mit denem Beispiel gearbeitet. Das setzen der Häkchen funktioniert hervorragend. Nur verschwinden tun die Kontrollkästchen nicht.

Welches Feld muß man eigentlich nehmen, wenn man das Script beim "Ziel" hinterlegen will. Frei nach dem Motto: "Wenn Häkchen 1 bis 4 gesetzt sind, dann setze auch dieses Häkchen."

Hier meine eMail: boller@thorlabs-hl.com

Avatar

Level 2

Problem gefunden !

Ich werd' weich in der Birne. Wenn ich das PDF mit dem Acrobat Reader öffne, dann gehts. Wenn ich die LifCycle PDF-Vorschau nehme, dann verschwinden die Felder nicht. Darauf muß man erst mal kommen.

Dennis

Thorlabs HL

Avatar

Level 4

Oke das mit dem ausserhalb von LCD hab ich nie probiert, wenns drin nicht ging ;D

> Welches Feld muß man eigentlich nehmen, wenn man das Script beim "Ziel" hinterlegen will. Frei nach dem Motto: "Wenn Häkchen 1 bis 4 gesetzt sind, dann setze auch dieses Häkchen."

Calculate und Validate wären Möglichkeiten. ABER VORSICHT: wenn du hier scripte reinschreibst, kann der Nutzer es wahrscheinlich nicht mehr überschreiben.

IdR. tust du gut daran die Scripte in der "Aktion" hineinzuschreiben, die er ausführt, wenn das Script gestartet werden soll.

Beispiel oben: MouseUp Javascript in Kontrollkästchen 1+2:

if (Kontrollkästchen1.rawValue == "1" && Kontrollkästchen2.rawValue == "1") {Kontrollkästchen3.rawValue = "1";}

if (Kontrollkästchen1.rawValue != "1" || Kontrollkästchen2.rawValue != "1") {Kontrollkästhen3.rawValue = "0";}

ändert das Häckchen von Kontrollkästchen 3, ist aber noch überschreibbar.

Lisa

Avatar

Level 2

Habe mittlerweile wieder etwas gelernt.

Die Vorschau hat das nicht mitgemacht, da die Vorschau standardmäßig

auf "static pdf" steht. Wenn ich das ganze auf "dynamisch" umschalte,

macht LCD auch das verstecken. Warum bei mir bei dynamischen

Dokumenten die Vorschau auf statisch war, kann ich nicht sagen.

>Calculate und Validate

Der wird den Zugriff blockieren. Das erklärt dann sehr gut die

Fehlermeldung die ich bekommen habe. Mal sehen wie ich das realisiere.

Ein anderer Knackpunkt ist aber:

Kann man das Formular mit dem Acrobat READER benutzen?

Der kann doch gar nicht speichern oder kann man da eine Option setzen?

Dennis

Avatar

Level 4

> Kann man das Formular mit dem Acrobat READER benutzen?

Also... mal grundsätzlich. Du kannst das Formular leer speichern.

Nachdem es ausgefüllt wird, wird es entweder gedruckt oder per XML versendet. Diesen XML Code kannst du dann in eine Datenbank einlesen lassen. (Wir haben das beispielsweise mit SAP gemacht.)

Alternativ kannst du auch das ganze als FESTES Formular speichern:

Ist unter den Druckoptionen... als pdf drucken. Ich weiß allerdings nicht, ob jemand hier bereits eine Lösung hat, um dafür nen eigenen Button zu bauen.

Eine weitere Option wäre, wenn du Lizensen von Adobe erstehst... dann kannst du es auch als veränderbares Formular speichern hast aber ggf. Beschränkungen beim Verteilen. Die Dinger sind allerdings teilweise recht teuer.

MfG

LISA

Avatar

Level 1

Could you please translate this solution into English.  I feel it will help me with an issue but I'm unaware of the proper script.

thank you,

Avatar

Level 4

Of course I'll do... but could you first tell me what exactly you wanted?

The three main themes we discussed were:

1) fields that will automatically filled

2) fields that get invisible by choices

3) possibilities to send data/save form

for 1) the original topic here, Paul's solution is the best. ^^

Avatar

Level 1

Would you be so kind to provide the solutions to topic number 1 and number 2. Thank you very much.

Edward Koehler

Avatar

Level 4

Hihi you have a German name too

Okey, if you only want to have fields, displaying exactly the same you can do it with bindings (like Paul suggested), with the masterpage (if the same field is on every page) or with scripting.

The last one is especially good, if you want to change something in the formatation, add something, calculations, changes or whatsoever ;D

If you work with multiple pages and/or subforms it could be that you need to refer to the full name of the specific field.

You normally can read the full name in the first line of the programming window.

Therefor sometimes you need to name the specific pages or subforms to get a correct "full name" of a field. (Otherwise there is the possibility your script won't work.)

One example of a calculated field including the in Javascript is:

this.rawValue = Page1.Textfield1.rawValue + " " +Page2.Textfield2.rawValue

(this.rawValue refers to the rawValue of the specific field that you write the script in)

To check checkboxes works similar:

if (Kontrollkästchen1.rawValue == "1" && Kontrollkästchen2.rawValue == "1") {Kontrollkästchen3.rawValue = "1";}

if (Kontrollkästchen1.rawValue != "1" || Kontrollkästchen2.rawValue != "1") {Kontrollkästhen3.rawValue = "0";}

if this script is started, Kontrollkästchen3 will be unchecked if either Kontrollkästchen1 or 2 are unchecked.

If both are checked, Kontrollkästchen3 will also be checked.

A formcalc script for one of my buttons (NULL is a checkboxname... because both were on the same page, same subform I didn't need the whole name):

if (NULL == 1) then Text1.presence ="hidden" else Text1.presence = "visible" endif

A similar solution in javascript; this time a radiobutton; in each radiobutton the mouse up event was the following:

if (this.rawValue == "1") {Dezimalfeld1.presence = "visible";}


if (this.rawValue == "2") {Dezimalfeld1.presence = "invisible"; Dezimalfeld1.rawValue = null;}


if (this.rawValue == "3") {Dezimalfeld1.presence = "invisible"; Dezimalfeld1.rawValue = null;}

(field.rawValue = null will delte the fieldentries.)

If you make hidden fields by choices, look up that when you check if it works it's set to dynamic.


One of the main issues in scripting also is, in which event you write the script.
Exit will just be executed when you leave a field. Therefor it is f.ex. good for Decimalfields and Textfields.
Calculate won't allow the user to change the entry.
Validate might give a errormessage.
Mouse up is good for checkboxes/radiobuttons as far as I know.
I also like to work with click and change events... though in the end I am just a beginner...

But if you want, you can tell me your specific problem and I look if I have a solution ;D
*Collects solutions*

oke... now I've said everything contained in the first two topics ;D
It nearly tells everything quite for beginners... (oke I am a noob myself... but my form's shapes get better and better ^^)

Avatar

Level 1

Thank you very much! I will check this out. Yes, I have a German last name but am also half Hawaiian and have never left the U.S.

Avatar

Level 2

Hi! Did I missed something? We have had a black out that killed my computer (power supply and CPU).

Ocen12 did a really good sum up. He also mentioned that the pdf preview of LifeCycle should be set to "dynamic". A point I did not checked so I thought that the script is not working. The third topic was about save data. There are also three (four) possiblities:

   (1) send the data back

   (2) print the PDF

   (3) If you create the pdf with LifeCycle you can set the pdf so that you can save a copy of the pdf form. More information is my system is back completely.

   (4) (If you have acrobat and not only the reader you can open the pdf with Acrobat.)

Dennis