how to get the field value? I write a javascript, but can't get field value.
var f = this.getField("DateTimeField1");
app.alert("val:"+f.value);
I find the text of the alert dialog is null. whether the function is not correct or have other function to get a field value in LiveCycle Designer by javascript.
My Product Information:
LiveCycle Designer Standard 8 / Windows
Offline

Add a field validator to the text field and try this script.
var t = this.getField("textInput"); // the target field
var cResponse = app.response({
cQuestion: "What do you like about Acrobat?",
cTitle: "Favorite Acrobat feature!"});
{
if ( cResponse == null)
app.alert("Please complete the question."); // if Cancel is selected
else
app.alert("You responded, \""+cResponse+"\", is this correct?",2);
}
t.value = cResponse; // places the data from the dialog to the target field
}
Offline

Create a text field and name it (I used target for the name in this example).
Add a button then click the Actions tab for the button Properties (this is done by right clicking the button).
Set the mouse up action and pasting this code for the Add Javascript option:
var t = this.getField("target"); // the target field
var cResponse = app.response ({ cQuestion: "What is your age?", cTitle: "Age Definition",}) ; // title of the dialog box
{
if (cResponse == null)
app.alert ("Please complete the question."); // if Cancel is selected
else
app.alert("You responded, \" "+cResponse+"\" , is this correct?", 3);
}
t. value = cResponse; // places the data from the dialog to the target field
Edit the response message, title, and question.
Note: This is an Acrobat script and it will not work in LiveCycle without modifying this script.
Offline
Eugene,
I tried the code that you sent. 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
Here is my javascript code:
var t = this.getField("TextField1"); // the target field
var cResponse = app.response({cQuestion: "What do you like about Acrobat?",cTitle: "Favorite Acrobat feature!"});
{
if ( cResponse == null)
app.alert("Please complete the question."); // if Cancel is selected
else
app.alert("You responded, \""+cResponse+"\", is this correct?",2);
}
t.value = cResponse; // places the data from the dialog to the target field
Any clues? Thanks!
Offline
danielha,
I just discovered that getField apparently doesn't work in LCD. Instead, you have to use resolveNode. To set the value of a field using resolveNode, you would do something like this:
xfa.resolveNode("[fieldname]").rawValue = "Hello, World";
(Replace [fieldname] with your field name.)
HTH,
Kathryn
Offline
AcrobatUsers.com >> User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in