Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Datum im PDF mit Javascript

New Here ,
Jun 23, 2021 Jun 23, 2021

Guten Morgen Zusammen,

ich wollte gerne in meinem Formular das Datum tagesaktuell automatiscg einfüllen lassen. Habe da auch etwas passendes gefunden. Habe mal den Javascript-Code unten kopiert:

 

var datum = this.getField("datum");
var jetzt = new Date();

var tag = jetzt.getDate();
var monat = jetzt.getMonth() +1;
var jahr = jetzt.getYear() +1900;

datum.value = tag+"."+monat+"."+jahr;

 

Sieht folgendermaßen aus: 24.6.2021

 

Ich habe in meine Dokumenten immer das Datum so geschrieben: 24.06.2021

 

Da ich ein Leihe bin was Programiersprachen angeht habe ich rumprbiert. Ohne Erflog.

Vielleicht kann mir einer von euch mal hierbei auch helfen.

 

Danke mal im Voraus

Christian_HUK

TOPICS
JavaScript
10.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2021 Jun 24, 2021

This code is not very good. You can do it like this:

 

var datum = this.getField("datum");
var now = new Date();
datum.value = util.printd("dd.mm.yyyy", now);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2021 Jun 24, 2021

Danke schön.

Es hat geklappt.

 

Grüße

Christian_HUK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 06, 2021 Jul 06, 2021

Hllo Zusammen,

ich muss leider nochmal zu diesem Thema nachhaken.

Irgendwie klappt da noch was nicht so richtig. Ich habe den Code von oben in das Textfeld-Eigenschaften im Raider Berechnung-Benutzerdef. Berechnungsskript eingefügt.

Nachdem Einfügen wurde das Datum richtig eingetragen.

Als ich es dann am nächsten Tag wieder geöffnet hatte wurde mir das Datum von gestern und nicht das von heute in der Vorlage angezeigt. Die Idee war aber das er mir immer das aktuelle Datum anzeigt. wenn ich die Vorlage öffne. 

Worin liegt der Fehler?

 

Grüße Christian_HUK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2021 Jul 06, 2021

If you want date to update when you open file you need to put script in "Document level javascript".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 06, 2021 Jul 06, 2021

Danke für die Rückantwort.

Wäre es möglich mir den genau Pfad aufzuzeigen, wo ich den Code hinkopieren soll.

 

Vielen Danke im Voraus

 

Christian_HUK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2021 Jul 06, 2021

When in 'Prepare form' tool, click on 'More', then select 'Document javascript' (or press CTRL+D), enter name for your script and click 'add' now delete everything that is inside new window that shows and paste your code here and click 'OK'.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2021 Jul 08, 2021

Danke für die Rückantwort.

Hat soweit funktioniert.

Ich habe noch eine Frgae ob dies machbar ist. 

 

Das Datum aktualisiert sich jetzt immer wenn ich das Formular öffne. Das ist auch richtig. Ich habe dieses Formular jetzt als Vorlage definiert.

So jetzt kommt meine Frage.

Die Vorlage wird ausgefüllt und mit einer Unterschrift versehen. Ab jetzt soll sich das Datum nicht mehr ändern.

Kann man das irgendwir programmieren, wenn ich auf "speichern unter" gehe, das sich das Datum nicht mehr ändert, auch wenn ich dieses Formular z.B. eine Woche später wieder öffne?

 

Danke fü eure Rückmeldungen.

 

Grüße

Christian_HUK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2021 Jul 08, 2021
LATEST

Use a empty field and set the date only when the field is empty. Before you save the template clear the field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2021 Jul 08, 2021

Everything you want to know is in this tutorial, (copy-paste this URL in Google Translate):

https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/champ-date-automatiq...


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines