Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Referencing subform instances in a dynamic pdf form

Avatar

Former Community Member
Hi all. No doubt this question will be pretty easy for experiences javascript programmers. Unfortunately, I'm not one of them and it is driving me nuts.



I have developed a survey for a client that gathers both quantitative and qualitative data. In one section of the survey I ask users to check all the checkboxes that apply. For each checkbox that is checked I generate a two textboxes (embeded in a subform) to gather some qualitative data. I am able to pass the number of the checkbox marked to the first checkboxes. However, I'm having problems deleting the appropriate subform is the client changes their mind and unchecks a checkbox. Essentially, the code only deletes the first instance, which is okay if only one checkbox was checked but problemative otherwise. I need to delete only the instance that pertains to the checkbox that was unchecked.



I would appreciate any help people can provide. I am attaching my code below.



Thanks,

Cristian



Check = 7 ; // value passed to recCheck textbox.

if (Rec7.rawValue == true) // if checkbox 7 is checked

{

Question2._Desc.addInstance(); // create new instance of subform Desc located in subform Question2

}

else if (Rec7.rawValue == false) // if checkbox 7 is not checked

{

for (i = 0; i <= 12; i++) // loop through all 13 checkboxes

{

if (WeeklyActivityLog[0].Question2[0].Desc[0].recCheck[0].rawValue == 7) // THIS CODE IS WRONG

{

Question2._Desc.removeInstance(i) ; // delete subform instance

break ; // exit for loop

}

}



}
2 Replies

Avatar

Former Community Member
Cristian,

Can you please post the structure of your form so I can get an idea of how it's laid out?

Something like this:



- BodyPage1

- Subform (Desc)

- Checkbox (recCheck)

- Subform (SF2)

- Checkbox (Rec7)



This will help me understand what you're trying to accomplish.



--

Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com

Avatar

Former Community Member
Justin,



I didn't check the forum in the past few days, so this is my first opportunity to respond. I've made some changes since I last posted. At the bottom is the current structure. I was able to devise a solution that works with IF-THEN statements. However, this required 30+ lines of code for each checkbox. I am certain that this could have been done more efficiently using a FOR loop. However, I did not know how to reference the subform instance.



Right now, I have a more critical problem that I am trying to deal with. I can't figure out how to bind the controls to a backend database create with MS Access. I followed the instructions but the data did not appear to save in the database. If anyone could help, I would be very grateful. There is nothing confidential, so I would not mind emailing the Acrobat form and Access database to anyone that would be interested in glancing at it. I doubt the solution is complicated, but I can't figure it out. I just need to understand how to do it for a few fields, particularly for the repeating fields in the subform, and I can process the rest myself.



Best regards,

Cristian Gugiu



WeeklyActivityLog

-Page(Question1)

-Text(Question1)

-Group(Checkboxes)

-Rec1

.

.

.

-Rec12

-Rec99

-Page(Question2)

-Text(Question)

-Subform(Desc)

-Text(recCheck)

-Text(recDescription)