Expand my Community achievements bar.

Popup window code is not working in acrobat pro XI

Avatar

Level 2

Hi

I prepared a form where user will fill information and a text box will populate when a specific user has updated the form. The form has many parts and different user will update own parts. I searched google and found below code (which is for xfa form).  I have very little knowledge in JavaScript coding. If anyone help me to use this code in my acroform, I would be highly greatful.

Thanks

var AHSC01 =

{

result:"cancel",

DoDialog: function(){return app.execDialog(this);},

strcode:"",

struser:"",

strpass:"",

SetListSel:function(list,path){if(path.length == 0) return;

eval("list[\""+ ((typeof path.join != "function")?path:path.join("\"][\"")) + "\"] = 1")},

GetListSel:function(oLstRslts,path){

   for(var item in oLstRslts){

      if( ((typeof oLstRslts[item]=="number")&&(oLstRslts[item]>0))

         || this.GetListSel(oLstRslts[item],path) )

       {path.push(item);return true;}

   }

   return false;

},

initialize: function(dialog)

{

var listuser =

{

"Andrew Rice": -2,

"Aaron Kelly": -3,

"Niall O'Donovan": -1,

};

this.SetListSel(listuser, this.struser);

var dlgInit =

{

"img1":

{

"width": 146,

"height": 39,

offset: 0,

"read": function(bytes){return ahsc1.slice(this.offset,this.offset+=bytes);}

},

"stat": "Document Security",

"sta1": "You are signing the document, as approved. \r\n\r\nPlease select your username and input your password (SafeCode + your unique code). Click Sign to approve. \r\n\r\nIf you do not wish to sign the document, click Cancel.",

"user": listuser,

"code": SafeCode, //timestamp

"pass": this.strpass,

};

dialog.load(dlgInit);

dialog.enable(

{

"code": true, // timestamp is editable, but it is now static text. If it was a textfield then set htis to false

}

    );

},

commit: function(dialog)

{

var oRslt = dialog.store();

this.strcode = oRslt["code"];

var path = new Array();

this.struser = ((this.GetListSel(oRslt["user"],path))?path.reverse():"").toString();

this.strpass = oRslt["pass"];

},

"cancel": function(dialog)

{

vUser.value = "";

vPass.value = "";

//dialog.load({"user":null});

//dialog.load({"pass":null});

},

description:

{

name: "AHSC Dialog",

elements:

[

{

type: "view",

elements:

[

{

type: "view",

align_children: "align_row",

elements:

[

{

type: "image",

item_id: "img1",

width: 146,

height: 39,

char_width: 4,

char_height: 4,

},

{

type: "static_text",

item_id: "stat",

width: 158,

height: 17,

alignment: "align_distribute",

font: "dialog",

bold: true,

},

]

},

{

type: "cluster",

item_id: "cls1",

name: "Signing Credentials",

char_width: 8,

char_height: 8,

font: "dialog",

bold: true,

elements:

[

{

type: "static_text",

item_id: "sta1",

name: "Static Text 1",

width: 283,

height: 135,

},

{

type: "view",

align_children: "align_row",

elements:

[

{

type: "view",

elements:

[

{

type: "static_text",

item_id: "sta3",

name: "SafeCode:",

font: "dialog",

bold: true,

},

]

},

{

type: "gap",

item_id: "gap1",

width: 13,

height: 40,

char_width: 4,

char_height: 4,

},

{

type: "view",

elements:

[

{

type: "static_text",

item_id: "code",

name: "code",

width: 134,

char_width: 8,

font: "dialog",

bold: true,

},

]

},

]

},

{

type: "view",

char_width: 8,

char_height: 8,

align_children: "align_row",

elements:

[

{

type: "view",

char_width: 8,

char_height: 8,

elements:

[

{

type: "static_text",

item_id: "sta1",

name: "Username:",

font: "dialog",

bold: true,

},

{

type: "gap",

item_id: "gap1",

width: 36,

height: 3,

char_width: 4,

char_height: 4,

},

{

type: "static_text",

item_id: "sta2",

name: "Password:",

font: "dialog",

bold: true,

},

]

},

{

type: "view",

char_width: 8,

char_height: 8,

elements:

[

{

type: "popup",

item_id: "user",

width: 108,

height: 23,

char_width: 8,

},

{

type: "edit_text",

item_id: "pass",

width: 134,

char_width: 8,

font: "dialog",

bold: true,

password: "true",

},

]

},

]

},

]

},

{

type: "ok_cancel",

ok_name: "Sign",

},

]

},

]

}

};

// Example Code

AHSC01.strcode = "";

AHSC01.struser = "";

AHSC01.strpass = "";

if("ok" == AHSC01.DoDialog())

{

//console.println("code:" + AHSC01.strcode);

//console.println("user:" + AHSC01.struser);

//console.println("pass:" + AHSC01.strpass);

vUser.value = AHSC01.struser;

vPass.value = AHSC01.strpass;

}

}

//TIMESTAMP SCRIPT FOR SAFECODE

function timeStamp()

{

var vTime = parseInt((new Date).getTime()/100000).toString();

var vTimestamp = vTime.substring(4,8);

return (vTimestamp);

}

//LETTER SCRIPT FOR SAFECODE

function letter()

{

chars = "ABCDEFGHJKLMNPQRSTUVWXYZ";

var sLetter = "";

  for(x=0;x<1;x++)

  {

    i = Math.floor(Math.random() * 24);

    sLetter += chars.charAt(i);

  }

  return (sLetter);

}

//NUMBER SCRIPT FOR SAFECODE

function number()

{

chars = "0123456789012345678901234567890123456789";

var sNumber = "";

  for(x=0;x<4;x++)

  {

    i = Math.floor(Math.random() * 40);

    sNumber += chars.charAt(i);

  }

  return (sNumber);

}

3 Replies

Avatar

Level 4

I moved your question to the LiveCycle Designer forum, as Acrobat forms and LCD forms are very different and require different kinds of scripts.

Avatar

Level 10

Hi there,

simply remove a bracket at the end of this if statement

Avatar

Level 2

Thanks for the reply.

In my form it has only 3 user. When I add user name in form it is showing below message

"Invalid signature, contact administrator."

I am adding username here

var listuser =

{

"Andrew Rice": -2,

"Aaron Kelly": -3,

"Niall O'Donovan": -1,

"Dawn Miller": -4,

"Dana Brown": -5,

"Mitchell Clark": -6,

};

I have to add 30 username.

I don't know why I am getting this message