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

AcroDialog Popup List update/store value

Explorer ,
Apr 01, 2024 Apr 01, 2024

Hello dear community. I am trying to update or save the value from the previous selection in the pop-up list. The "Name" and "Surname" fields are fine, but the pop-up list ("Title") is not. Can anyone help me with this? When the user clicks the button, the value from the previous selection should be displayed. Any help would be appreciated.

Bildschirmfoto 2024-04-01 um 17.05.50.png

 

list_Titl = {"--Select--":-1,"Ms":-1,"Mrs":-1,"Mr":-1};
var oDlg = {
	strTitle:null,
	strEdt1:null,
	strEdt2:null,
	GetListSel:function(oLst){for(var x in oLst){if(oLst[x]>0)return x;}return null;},
	initialize:function(dialog){
		var oInit = {
			Titl:this.strTitle,
			Name:this.strEdt1,
			Snam:this.strEdt2,
			Titl:list_Titl
		};
		dialog.load(oInit);
	},
	validate:function(dialog){
		var bRtn = true;
		var oRslt = dialog.store();
		return bRtn;
	},
	commit:function(dialog){
		var oRslt = dialog.store();
		this.strTitle = this.GetListSel(oRslt.Titl);
		this.strEdt1 = oRslt.Name;
		this.strEdt2 = oRslt.Snam;
	},
	description:{
		name:"Dialog Box",
		elements:[{type:"view",elements:[
		{
			type:"view",
			item_id:"Vew1",
			alignment:"align_fill",
			align_children:"align_left",
			elements:[
				{
					type:"static_text",
					item_id:"Sta1",
					name:"Title",
				},
				{
					type:"popup",
					item_id:"Titl",
					alignment:"align_fill",
				},
				{
					type:"static_text",
					item_id:"Sta2",
					name:"Name",
				},
				{
					type:"edit_text",
					item_id:"Name",
					width:35,
					alignment:"align_fill",
				},
				{
					type:"static_text",
					item_id:"Sta3",
					name:"Surname",
				},
				{
					type:"edit_text",
					item_id:"Snam",
					width:35,
					alignment:"align_fill",
				},
			],
		},
		{
			type:"ok_cancel",
		},
	]}]
	}
};

oDlg.strTitle = this.getField("Title").value;
oDlg.strEdt1 = this.getField("Surname").value;
oDlg.strEdt2 = this.getField("Name").value;

if ("ok" == app.execDialog(oDlg)) {

	this.getField("Title").value = oDlg.strTitle;
	this.getField("Surname").value = oDlg.strEdt1;
	this.getField("Name").value = oDlg.strEdt2;

}

 

 



TOPICS
JavaScript , Modern Acrobat , PDF , PDF forms
504
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 01, 2024 Apr 01, 2024

This looks like custom dialog code created with AcroDialogs

There is a slight error in the code generation. The initialize function should not be using the input value for the dropdown directly. The only value that can be loaded into a list/dropdown is the list object, "list_Titl".

So the missing element here is a function for setting the selected entry in the list object to a +1. 

 

function SetListItem(oList, cValue)
{
    for(var nm in oList)
       oList[nm] = (nm == cValue)?1:-1;
    return oList;
}

 

 

Now this function can be used in the Initialize function 

 

	initialize:function(dialog){
		var oInit = {
			Name:this.strEdt1,
			Snam:this.strEdt2,
			Titl:SetListItem(list_Titl, this.strTitle),
		};
		dialog.load(oInit);

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
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 ,
Apr 01, 2024 Apr 01, 2024

This looks like custom dialog code created with AcroDialogs

There is a slight error in the code generation. The initialize function should not be using the input value for the dropdown directly. The only value that can be loaded into a list/dropdown is the list object, "list_Titl".

So the missing element here is a function for setting the selected entry in the list object to a +1. 

 

function SetListItem(oList, cValue)
{
    for(var nm in oList)
       oList[nm] = (nm == cValue)?1:-1;
    return oList;
}

 

 

Now this function can be used in the Initialize function 

 

	initialize:function(dialog){
		var oInit = {
			Name:this.strEdt1,
			Snam:this.strEdt2,
			Titl:SetListItem(list_Titl, this.strTitle),
		};
		dialog.load(oInit);

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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
Explorer ,
Apr 01, 2024 Apr 01, 2024
LATEST

Thanks, Thom. Yes, you are right, I use your AcroDialog under (https://www.pdfscripting.com/members/AcroDialogs.cfm) The function has worked for me. Thanks again for your help, Thom.

Translate
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