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

Javascript Dialog Checkbox Undefined

New Here ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

I have a form with javascript and I'm trying to add a checkbox to a dialog, but it always returns undefined. The first checkbox works fine, but I cannot figure out why the second one with id "ckbox2" doesn't.  The alert says it's undefined so it never goes into the if statement. I didn't write this code, I'm just trying to add the checkbox, but I don't see where it's wrong, any help is appreciated.

 

Here's the snippet:

function f_getCheck()
{
if(this.getField("numCks").value>9){app.alert("You may only include ten items in a deposit with a hold!");end;}
var y = this.getField("numCks").value;
var z = this.getField("t_Code."+ y).value;
if(z=="E"){f_getCkReason()};
var dialog8 = {
	initialize: function(dialog){
		this.test1 = "";
		this.test2 = "";
},
	validate: function(dialog){
		var val = dialog.store();
		this.test1 = val["rtno"];
		this.test2 = val["iamt"] * 1;
		if(this.test1.length==9&&(this.test1*1)>0&&this.test2>0){
		fcb_ABA(this.test1, this.test2);
		} else {
		app.alert("Routing Numbers must be nine digits and amounts must be greater than zero");
		return false};
		return true;
	},
	commit: function(dialog){
		var results=dialog.store();
		this.RTNum = results["rtno"];
		this.Amt = results["iamt"];
		this.ExCkHold = results["ckbx"];
		this.RetCk = results["ckbox2"];
		app.alert(this.RetCk);
	},
	ok: function(dialog){
		var results=dialog.store();
		dialog.end("ok");

	},

	cancel: function(dialog){
		var results=dialog.store();
		dialog.end("del");

	},
	other: function(dialog){
		var results=dialog.store();
		dialog.end("done");
	},

	loadDefaults: function(dialog){},
	description: {
		name: "Check Entry",
		elements: [{
			type: "view",
			align_children: "align_left",
			elements:[{
				type: "cluster",
				name: "Enter the information for the check.",
				align_children: "align_row",
				elements:[{
					type:"view",
					align_children:"align_left",
					elements:[{
    						type:"static_text",
						name:"Routing/Transit Number"},
						{item_id:"rtno",
						type:"edit_text",
						char_width: 9}
					]},
					{type:"view",
					align_children:"align_left",
					elements:[{
						type:"static_text",
						name:"Amount of item (xxxx.xx)"},
						{item_id:"iamt",
						type:"edit_text",
						char_width: 12}]}]},
						{type:"check_box",
						item_id: "ckbx",
						name: "Check here to exclude from amount on hold and deposit information."},
						{type: "check_box",
						item_id: "ckbx2",
						name: "Check here if this is an Exempt item."},
						{type: "static_text",
						name: "Exempt items include items drawn on state, local, U.S. governments, cashier's checks, and the like.",
						italics:true},
						{type: "ok_cancel_other",
						ok_name: "Add check to deposit",
						cancel_name: "Delete an item",
						other_name: "No more items"}]}]}};

var myResult = app.execDialog(dialog8);
if(myResult=="done"){f_AllDone()};
if(myResult=="cancel"){f_delItems()};
if(myResult=="ok"){
	if(dialog8.ExCkHold==true){
		this.getField("t_Code."+(this.getField("numCks").value-1)).value = "";
		this.getField("ExType."+(this.getField("numCks").value-1)).value="";
		this.getField("RT."+(this.getField("numCks").value-1)).value="";
		this.getField("ckAmt."+(this.getField("numCks").value-1)).value="";
		this.getField("numCks").value--;
	}
	else {
		if(dialog8.RetCk==true){
		this.getField("ExType." + (this.getField("numCks").value-1)).value = "-Exempt-\rOther";
		var xx = this.getField("numCks").value*1-1;
		var xxx = this.getField("t_Code." + xx).value;
		if(xxx=="A"){} else {this.getField("t_Code." + (this.getField("numCks").value-1)).value = "-"};
		if(xxx=="F"){this.getField("t_Code." + (this.getField("numCks").value-1)).value = "F"}
		};
	};
	f_getCheck()
};
}

 

TOPICS
Acrobat SDK and JavaScript

Views

148

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

I realized that the snippet here shows ckbox2 and ckbx2 but regardless even if they're the same it doesn't work

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

You can't call the function from within itself (well, you can, but you'll end up with an endless loop...).

Move the call to f_getCheck() outside of the function definition and try again.

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

I see, well that was done with the intention that the user could enter multiple checks so the dialog keeps opening until they click done. It didn't cross my mind that could be affecting it

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

You can do that, but then you must add some condition to get out of that loop, and you still need to have one initial call from outside of it.

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

Ok, well I tried taking out that call from within itself to test, but it still does not get that second checkbox 😞

 

Thanks in advance for your help!

Likes

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 ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

LATEST

I was able to work around this by just creating two new dialogs for each checkbox since really it can only be one or the other, and now it works how it should.

Likes

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