Java Script für Formular - yyyymmddHHMMss
Copy link to clipboard
Copied
Hallo zusammen,
ich würde gerne unsere Lieferscheine durchnummerieren. Dazu möchte ich ein Formularfeld, welches beim öffnen des Formulars eine Kombination aus Datum und Uhrzeit erzeugt und danach einfach nicht mehr aktualisiert wird.
Ganz ohne Schnick-schnack. Also einfach "yyyymmddHHMMss" - da bei uns sicher niemals 2 Lieferscheine in der selben Sekunde erzeugt werden, reicht das völlig aus.
Ich habe nun schon viele Scripte ausprobiert aber keines funktioniert. Leider bin ich in Java eine Niete - bis auf leichte Anpassungen versage ich.
Vielleicht hat jemand eine Idee.
Vielen Dnak im Voraus!
Copy link to clipboard
Copied
What scripts have you tried?
Copy link to clipboard
Copied
z.B. dieses hier
now = new Date();
year = now.getFullYear();
month = now.getMonth() + 1;
day = now.getDate();
hour = now.getHours();
minute = now.getMinutes();
second = now.getSeconds();
console.log(`year is ${year}`);
console.log(`month is ${month}`);
console.log(`day is ${day}`);
console.log(`hour is ${hour}`);
console.log(`minute is ${minute}`);
console.log(`second is ${second}`);
Copy link to clipboard
Copied
console.log will not work in Acrobat. It will work in web browsers.
Copy link to clipboard
Copied
Also das Script habe ich jetzt erstellt und es funktioniert auch genau wie gewollt.
Ich poste es hier, falls wieder mal jemand das Problem hat.
var Datum = new Date();
var Tag = Datum.getDate();
var Monat = Datum.getMonth() + 1;
var Jahr = Datum.getFullYear();
var Stunden = Datum.getHours();
var Minuten = Datum.getMinutes();
var Sekunde = Datum.getSeconds();
if (Minuten < 10){
Minuten= "0" + Minuten;
}
if (Tag < 10){
Tag = "0" + Tag;
}
if (Monat < 10){
Monat = "0" + Monat;
}
if (Sekunde <10){
Sekunde = "0" + Sekunde;
}
document.write( Jahr + Monat + Tag + Stunden + Minuten + Sekunde );
Die Ausgabe sieht dann so aus "20220809115005"
Gibt es einen Befehl, damit ein bestimmtes Feld zu füllen?
Copy link to clipboard
Copied
document.write will work in a web browser, not in Adobe Acrobat.
Copy link to clipboard
Copied
and what would work in Adobe Acrobat?
Copy link to clipboard
Copied
Something like this:
this.getField("Feldname").value = Jahr + Monat + Tag + Stunden + Minuten + Sekunde;
Copy link to clipboard
Copied
Thank you - works pferfect!
Copy link to clipboard
Copied
Once the proper syntax is used, this code will work fine:
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
console.println("year is "+year);
console.println("month is "+month);
console.println("day is "+day);
console.println("hour is "+hour);
console.println("minute is "+minute);
console.println("second is "+second);
Copy link to clipboard
Copied
auch dieses
var datumNeu = new Date(); var f = this.getField("Feldname"); f.value = datumNeu;
Copy link to clipboard
Copied
To show a message you can use app.alert

