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

script to ask user click a form field then change the field

New Here ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Folks,

 

Does any one have a sample javascript code which

1. Ask user to click a text field.

2. Script get the name of the text field which user clicked.

3. Input something into the text field.

 

Thank you for your help.

--AL

TOPICS
Acrobat SDK and JavaScript

Views

329

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

There's no way to do that with just a single script. You'll need to attach a script to the On Focus event of each field in the file to be able to detect which field they selected.

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

LATEST

Thanks for your time. 

I am a beginner, I just form SOME form fields in my pdf.

My  temperary fix is like this:

 

function formatThis()
{
   var fldName = event.target.name;
   var fld = this.getField( fldName );
   fld.alignment = 'right';
   fld.setAction("Format", "AFNumber_Format(0, 0, 0, 0, '', true);");
   app.beep(0);
   app.alert(' formated field: ' + fldName,3);
}

var fldCnt =0 ;
var textCnt = 0 ;
var selTextCnt = 0;
for ( var i=0; i < this.numFields; i++) {
    fldCnt += 1;
    var f = this.getField(this.getNthFieldName(i));
    f.setAction("MouseUp", " ");
    if ( f.type == 'text' ){
        textCnt += 1;
        f.setAction('MouseUp', 'formatThis()' );
    }
console.println( 'field cnt='+ fldCnt ) ;
console.println( 'text cnt='+ textCnt );
console.println( 'text sel='+ selTextCnt );

 

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