Expand my Community achievements bar.

Positioning a picture placeholder generated by a button

Avatar

Level 2

Hi. Have built a form in LiveCycle to be completed via reader. Has buttons to add optional repeating 'Opportunity' subform.

Within this subform there is a button to generate an additional picture placeholder subform.

Problem is can generate 'Opportunity' subforms (2, 3 etc) but additional picture placeholder always appears in first instance of opportunity subform regardless whether generated from button in (say) opportunity subform 3.

Phew!

Maybe easier to have the whole file?

No option to upload here anymore?

Thanks

5 Replies

Avatar

Former Community Member

Does the image 'placeholder' have width and height properties or are they null?

Regarding upload, the default click behaviour of an ImageField is to enable a file explorer to pick an image field.

Steve

Avatar

Level 2

Hi Steve

Image placeholder is an image filed with defined dimensions

form1.OpportunitySubform.PicandTextSubform.PicSubform.AddPictureButton::click - (JavaScript, client)

// nSubLength stores the number of XML elements contained in Subform1.

// var nSubLength = OpportunitySubform.nodes.length;

// nNumSub is used to calculate the number of subform objects contained in Subform1.

// var nNumSub = 0;

// This script uses a For loop to cycle through all of the objects contained

// in Subform1.

// for (var nCount = 0; nCount < nSubLength; nCount ++) {

// If the current XML element in Subform1 is of type subform, then increment

// the variable nNumSub by one.

// if (OpportunitySubform.nodes.item(nCount).className == "subform") {

// nNumSub = nNumSub + 1;

// }

// }

// An if-else statement is used to prevent form authors from adding more than the

// maximum number of five subform instances to a form.

// if (nNumSub == 5) {

// xfa.host.messageBox("The maximum allowable number of subforms is 5. You cannot add any more subforms.", "Warning", 3);

// }

// else {

// This script uses the addInstance() method to add a new instance of the

// Subform2 object contained in Subform1.

// form1.OpportunitySubform.PicandTextSubform.PicSubform.instanceManager.addInstance(1);

// }

if

(form1.OpportunitySubform.PicandTextSubform.PicSubform.instanceManager.count<5) {

// This script uses the addInstance() method to add a new instance of the

// Subform2 object contained in Subform1.

form1.OpportunitySubform.PicandTextSubform.PicSubform.instanceManager.addInstance(1);

}

else

{

xfa.host.messageBox("The maximum allowable number of subforms is 5. You cannot add any more subforms."

, "Warning", 3);

}

That's the code. Can add a new subform 1 fine.

If I then generate a new pic in the second instance of subform 1 it places the pic in the first instance of subform 1.

Avatar

Former Community Member

Hard to debug without seeing the form in its entirety. I put together the attached that uses an ImageField, a button and a positioned sub-form within a flowed sub-form. It adds the image correctly although I am not sure if this is the approach you are intending to use.

Steve

Avatar

Level 2

Sorry did not explain very well. The form (see last post) works very well up to....

I have a report which contains a subform 1. Within that subform I have a button to generate an additional, optional picture placeholder,

The user can also generate another instance of subform 1

When a second instance of subform 1 is generated using the add picture button always generates the picture placeholder in the original subform 1 and not in the new instance of subform 1

Hope that's clearer. I'm sure it would be easier to download the file (last post) or is there a way I can upload it here?

Thanks

Graham