These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

unable to use getField in Javascript

danielha
Registered: Jan 7 2008
Posts: 6

Here is the javascript code that I have on the click event of a button:

----- form1.#subform[0].Button1::click: - (JavaScript, client) -------------------------------------

var fld = this.getField("TextField1");

fld.value = util.printd("yyyy/mm/dd",new Date());

When I click on the button I got the following error in the javascript debugger:

this.getField is not a function
1:XFA:form1[0]:#subform[0]:Button1[0]:click
this.getField is not a function
1:XFA:form1[0]:#subform[0]:Button1[0]:click

Please help. Thank you.

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Do not mix AcroForms JavaScript with LiveCycle Designer JavaScript or FormCalc.

You could try:

$.formattedValue = util.printd("yyyy/mm/dd", Date.getDate());

From a previous post:

For Acrobat forms you can use the following document level JavaScirpt to imput the current date into a formatted field called "Current Date":

this.getField("CurrentDate").value = new Date();

In LiveCycle Designer one can use

Num2Date(Date());

in the calculation field to input the current date



There is more information about using JavaScript and FormCalc in LiveCycle Designer's Help menu option.

George Kaiser