Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Hidden subform connected to dropdown object

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

31-08-2020

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);

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

31-08-2020

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
	}
}

 

Answers (0)