Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2007-12-26 11:19:35

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Text field prepend append

Is it possible to add a character to a fillable text field? for instance a text filed asks for name so they type John, I want to have a < or something added to that field on a var this.getField command.


My Product Information:
Acrobat Pro 8.1 / Windows

Offline

 

#2 2007-12-28 08:45:47

pddesigner
Member

Registered: 2007-04-24
Posts: 55

Re: Text field prepend append

Add a text field(textInput) and add a button(btnAsk)

Change the cQuestion and cTitle with your question and title.

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
}

Second option:

Create a button(btnQuestion) and text field (UserName). Modify the code to add the special character.

Add this Javascript to the buttons Mouse Up action:
// Dialog Definition
var oDlg =
{
   strName: "",
   initialize: function(dialog)
   {
      dialog.load({"usnm":this.strName});
   },
   commit: function(dialog)
   {
      var data = dialog.store();
      this.strName = data["usnm"];
   },
   description:
   {
      name: "Test Dialog",
      elements:
      [
         {
            type: "view",
            elements:
            [
               {
                  name: "Enter your name:",
                  type: "static_text",
               },
               {
                  item_id: "usnm",
                  type: "edit_text",
                  char_width: 15
               },
               {
                  type: "ok_cancel",
               },
            ]
         },
      ]
   }
};
// Dialog Activation
oDlg.strName = this.getField("UserName").value;
if("ok" == app.execDialog(oDlg))
{
    this.getField("UserName").value = oDlg.strName;
}

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in