Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Hidden subform connected to dropdown object

Avatar

Level 9

I have a drop-down list object labeled "Question" that contains items: Yes, No, N/A

When the user selects "Yes" the hidden sub-form becomes visible.

That sub-form contains three text-fields.

If the user types data into any of these three text fields and then changes their mind and selects either "No" or "N/A" from the drop-down, I want to delete and data that was entered into the text-fields in the sub-form then hide the sub-form.

 

This is the script I am using but when the user is warned they about to delete the data they entered into the 3 text-fields and they choose No - they do not want to continue, the drop-down goes to "No" anyway even though i have the script that says to make it go back to "Yes". What am I doing wrong?

 

Form1.Table1.Row[0].Question::change - (JavaScript, client)
if ($.boundItem(xfa.event.newText) == "Yes"){
this.resolveNode("Additional00").presence = "visible";
}
if ($.boundItem(xfa.event.newText) == "No"){
var nResponse = xfa.host.messageBox("If you entered anything in the Supplier Description, SupplierReason or SupplierSubstantiation text fields it will be deleted. \n\nDo you want to continue?", "Deleting Data", 1, 2)
if (nResponse == 3){
($.boundItem(xfa.event.newText) == "Yes");
}
if (nResponse == 4){
this.resolveNode("Additional00.Subform4.SupplierDescription").rawValue = null;
this.resolveNode("Additional00.Subform4.SupplierReason").rawValue = null;
this.resolveNode("Additional00.Subform4.SupplierSubstantiation").rawValue = null;
this.resolveNode("Additional00").presence = "hidden";
}
if (xfa.host.version < {
xfa.form.recalculate(1);

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi, 

 

you can do this with much less code. Also, the messageBox methods returns 4 when pressing the Yes-button. 

var cSel = xfa.event.change, // current selection
	cPrevSel = xfa.event.prevText; // previous selection

if (cSel === "Yes") {
	Additional00.presence = "visible"; // show subform
} else if (cSel === "No" && cPrevSel !== "No") {
	if (xfa.host.messageBox("If you entered anything in the Supplier Description, SupplierReason or SupplierSubstantiation text fields it will be deleted. \n\nDo you want to continue?", "Deleting Data", 1, 2) === 4) {
		Additional00.presence = "hidden"; // hide subform
		xfa.host.resetData(Additional00.somExpression);	// reset subform data
	} else {
		xfa.event.change = cPrevSel; // restore previous state, if user selected no
	}
}

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi, 

 

you can do this with much less code. Also, the messageBox methods returns 4 when pressing the Yes-button. 

var cSel = xfa.event.change, // current selection
	cPrevSel = xfa.event.prevText; // previous selection

if (cSel === "Yes") {
	Additional00.presence = "visible"; // show subform
} else if (cSel === "No" && cPrevSel !== "No") {
	if (xfa.host.messageBox("If you entered anything in the Supplier Description, SupplierReason or SupplierSubstantiation text fields it will be deleted. \n\nDo you want to continue?", "Deleting Data", 1, 2) === 4) {
		Additional00.presence = "hidden"; // hide subform
		xfa.host.resetData(Additional00.somExpression);	// reset subform data
	} else {
		xfa.event.change = cPrevSel; // restore previous state, if user selected no
	}
}