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

Java Script für Formular - yyyymmddHHMMss

New Here ,
Aug 08, 2022 Aug 08, 2022

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!

TOPICS
JavaScript , PDF forms

Views

543

Translate

Translate

Report

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

Copy link to clipboard

Copied

What scripts have you tried?

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

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?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

and what would work in Adobe Acrobat?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Something like this:

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you - works pferfect!

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

auch dieses

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

To show a message you can use app.alert

Votes

Translate

Translate

Report

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