Expand my Community achievements bar.

SOLVED

hide or show a sub-form whith check a check box

Avatar

Level 2

Hi,

I don't know how to do this.

I can't put it in "on click" because click can check or uncheck the box.

Pls help me

thx

Nath

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Nath,

I don't understand. The usual approach is to allow the user to tick the checkbox, eg ticked = subform is visible, unticked = subform is hidden.

Is this what you are after?

If so this should work in the click event:

if (this.rawValue == 1)

{

     subform.presence = "visible";

}

else

{

     subform.presence = "hidden";

}

If you are after some other behaviour, can you explain further.

Niall

Assure Dynamics

View solution in original post

15 Replies

Avatar

Correct answer by
Level 10

Hi Nath,

I don't understand. The usual approach is to allow the user to tick the checkbox, eg ticked = subform is visible, unticked = subform is hidden.

Is this what you are after?

If so this should work in the click event:

if (this.rawValue == 1)

{

     subform.presence = "visible";

}

else

{

     subform.presence = "hidden";

}

If you are after some other behaviour, can you explain further.

Niall

Assure Dynamics

Avatar

Level 2

thx a lot ! It's excactly what i've searched !


Avatar

Level 2

I still have a problem :

I would like every subforms are hidden in the beggining.

When user check one or several boxes, then subform(s) appears.

Now, if i let subforms visible, they disapeard after check and uncheck the boxes

If I choose "hidden", the combo box don't work anymore...

Pls help.

Sorry, i'm french and bad in english. I hope my message is understable...

Avatar

Level 10

Hi Nath,

It might be easier if I could see the form. Can you share it? It is probably a small issue with the script. If you can't share the form, can you post the script that you are using and the event?

There is an example here that looks at the different presence settings:

http://www.assuredynamics.com/index.php/category/portfolio/changing-an-objects-presence-and-relevant...

If you want the subforms hidden initially, you can set this in LC Designer in the Object > Field palette. Set the presence to hidden. I think this is what you have already done, but I am not sure.

Niall

Assure Dynamics

Avatar

Level 2

Yes, that what i've done but don't work

I've just succed to make work "site" and "service" but fonction and spécialité still don't work anymore...

How can I join the form ?? I can't find any button to uplaod a file...!?

Avatar

Level 10

Hi Nath,

You can't upload files directly to the forum.

If you go to http://www.acrobat.com (or another file sharing site) and upload you form there. You will need to publish the form and then share the published link here:

Acrobat.com.png

Niall

Avatar

Level 2

Don't work, i guess it's a restriction form DSI for people from my company

Here you are, the piece of code which doesn't work (on click event)


{
     formulaire1.fonct.tit.tit.presence = "visible";
     formulaire1.fonct.tit.rq2.presence = "visible";
    
    formulaire1.fonct.spe.presence = "visible";
    formulaire1.fonct.com.presence = "visible";
    formulaire1.val_dr.presence = "visible";    
}
else

{
      formulaire1.fonct.tit.tit.presence = "hidden";
     formulaire1.fonct.tit.rq2.presence = "hidden";
    
    formulaire1.fonct.spe.presence = "hidden";
    formulaire1.fonct.com.presence = "hidden";
    formulaire1.val_dr.presence = "hidden";  
}

Avatar

Level 2

Hi Niall,

I'm having a similar problem and I'm wondering if I might have some of your time.

I think I'm attempting to program my form to perform the same function as Nath.  I'm wondering if it's necessary to wrap the checkbox that corresponds with the text I'm trying to control (hide/show) within the same subform.  Right now the checkboxes are not wrapped within the same subform as my text and the click event is not working as I expected.

Thanks for your help, I appreciate it very much.

Amanda

Avatar

Level 10

Hi Amanda,

No, you do not have to have the checkbox and the object in the same subform. What's important is that you are referencing the object correctly, so that the script changes the presence property.

When you have the form open in LC Designer Preview OR in Acrobat you can press Control+J to open the Javascript console. This can help to debug the form. When you tick and untick the checkbox do errors appear in the console?

If the checkbox is showing/hiding a single object then there is no need to wrap it in a subform. If however the checkbox is show/hiding many objects then it can be useful to wrap these in a subform and have the checkbox show/hide the subform as one operation.

When referencing objects in the script it is vital that you respect the hierarchy. So if the checkbox is in a separate subform to the object it is referencing you will need to include the intervening subform names. There is an example here that looks at referencing objects:

http://www.assuredynamics.com/index.php/category/portfolio/referencing-objects/

Other than that, can you share the form?

Niall

Assure Dynamics

Avatar

Level 10

Hi,

I don't think you have published the file, as I can't access the file.

You need to publish the file first anf then copy the link:

Acrobat.com.png

Niall

Avatar

Level 10

Hi Amanda,

Here is your form back:

https://acrobat.com/#d=9guLWq1oN6yE4jtaoCGU1g

You didn't have the objects referenced correctly. You had the two text objects in subforms, which is fine. So I have left them in the subforms and set the presence of the subforms to hidden in the Object > Field palette.

Have a look at the script in the clcik events of both checkboxes. These reference the subforms.

I have also set the page to flowed, so that when the text objects are hidden, the space will be freed up for objects to move up. If in LC Designer you want to see the objects, just select the subform in the hierarchy and in the Object > Field change the presence from hidden to visible.

Hope that helps,

Niall

Assure Dynamics