5

The goal is for an Acrobat form to fill a date field ("MeetingDate") with Today's date when the user opens it. If the user saves the form as is and opens it a few days later, the old date should still be there, not replaced by the current date. If the user changes date in the field, that date should be saved and should not be replaced when the form is opened later.

I have a Custom Calculation Script for a date field ("MeetingDate") that does all of this, but with one problem:

if (event.value != "")
then
event.value = util.printd ("m/d/yyyy", new Date())
endif

This works well except that after entering the script, today's date fills in the MeetingDate field and the value is saved. That makes sense, but I want the field to be automatically filled with Today's date when the user opens the form. Instead, if the user opens the form tomorrow (7/16/2010) it will have 7/15/2010 in the field because that is the date I saved the form.

I think the answer may be to enter a script as a Document JavaScript (Advanced | Document Process | Document JavaScripts), since Document scripts execute when the form is opened, but all my attempts cause a date entered by the user to be overwritten when the form is opened days later. Thanks for the help!

4

4 に答える 4

10

スクリプトを削除し、次のドキュメント JavaScript に置き換えます。

var f = this.getField("wells_datefield");
if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());

フォームを保存して開くと、日付がすぐに表示されます。

ドキュメントを JavaScript にするときは、 function 内に配置しないように注意してください。それを行う1つの方法は次のとおりです。アクロバット メニュー:

  1. Advanced->Document Processing->Document Javascripts...
  2. ポップアップするダイアログで、スクリプト名 (「populate_date」など) を入力し、[追加...] をクリックします。
  3. ポップアップするスクリプト ダイアログで、すべてを削除 ("function populate_date(){}") し、上記のスクリプトを貼り付けます。
  4. [OK] をクリックしてから、[閉じる] をクリックします。
  5. フォームを保存して閉じ、再度開きます。
  6. ステップ6はありません!:>
于 2010-07-16T08:49:08.443 に答える
1

@ウェルズ・アンダーソン

if ステートメントを削除するだけです。

event.target.value = util.printd("m/d/yyyy", new Date());
于 2015-10-02T22:23:13.377 に答える
1

英国のユーザー (および私のような初心者) のために、このコードの編集を追加してもかまいません。

var f = this.getField("date");
if (!f.value) f.value = util.printd ("dd/mmm/yyyy", new Date());

このコードは、次のように日付フィールドを埋めます...

03/Jan/2013
于 2013-01-03T22:37:50.097 に答える
0

残念ながら、 var f = this.getField("DatepPrinted"); を追加すると if (!f.value) f.value = util.printd ("dd/mmmm/yyyy", new Date()); フォームのカスタム キーストロークに、2015 年 4 月 2 日ではなく「0」が返されます。

于 2015-04-02T13:41:58.327 に答える