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

Java Script für Formular - yyyymmddHHMMss

New Here ,
Aug 08, 2022 Aug 08, 2022

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!

TOPICS
JavaScript , PDF forms
966
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 ,
Aug 08, 2022 Aug 08, 2022

What scripts have you tried?

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 ,
Aug 08, 2022 Aug 08, 2022

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}`);

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 ,
Aug 08, 2022 Aug 08, 2022

console.log will not work in Acrobat. It will work in web browsers.

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 ,
Aug 09, 2022 Aug 09, 2022

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?

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 ,
Aug 09, 2022 Aug 09, 2022

document.write will work in a web browser, not in Adobe Acrobat.

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 ,
Aug 09, 2022 Aug 09, 2022

and what would work in Adobe Acrobat?

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 ,
Aug 09, 2022 Aug 09, 2022

Something like this:

this.getField("Feldname").value = Jahr + Monat + Tag + Stunden + Minuten + Sekunde;

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 ,
Aug 09, 2022 Aug 09, 2022
LATEST

Thank you - works pferfect!

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 ,
Aug 08, 2022 Aug 08, 2022

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);
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 ,
Aug 08, 2022 Aug 08, 2022

auch dieses

var datumNeu = new Date(); var f = this.getField("Feldname"); f.value = datumNeu;

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
LEGEND ,
Aug 09, 2022 Aug 09, 2022

To show a message you can use app.alert

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