These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Hide/show (sub)fields with a check box

Rkorpel
Registered: Mar 25 2008
Posts: 12
Answered

Hey peeps,

I am working on a PDF form in live cycle designer 8.0 where we can fill in overwork hours. But i want to hide some fields with a checkbox when they are not needed. I am fighting this thing for a week now and i am still without a working checkbox :(

I have googled so much, that i am afraid that google is going to send me a bill :)

I know there are some tread with hide/view options, but i havent found a tread that solved my problem. I am a rookie on this thing, so i hope u can explain it as simple as posible.

Thank u for your time, and i hope u want to help me out!

Cheers,

Roy

My Product Information:
LiveCycle Designer, Windows
R_Boyd
Registered: Nov 1 2007
Posts: 151
Using form calc apply this to the exit event for the checkbox.

if ($.rawValue == 1) thenyour_field.presence	= "visible"elseyour_field.presence	= "hidden"endif

You should also apply the appropriate script to the formReady event e.g. if you don't want the field to be visible initially you should set the presence to hidden.

You can also wrap your selected fields in a subform and then set the presence to hidden to hide all of them.

Note that hidden subforms will not be counted in your layout. This can be very handy but ensure that the form is set to Flow content rather than position content.

If you are just starting with Designer JP Terry's book on using LiveCycle Designer is a good start and has a section on this topic. The recent eSeminar may also be helpful.
Rkorpel
Registered: Mar 25 2008
Posts: 12
R_Boyd wrote:
Using form calc apply this to the exit event for the checkbox.
if ($.rawValue == 1) thenyour_field.presence	= "visible"elseyour_field.presence	= "hidden"endif

You should also apply the appropriate script to the formReady event e.g. if you don't want the field to be visible initially you should set the presence to hidden.

You can also wrap your selected fields in a subform and then set the presence to hidden to hide all of them.

Note that hidden subforms will not be counted in your layout. This can be very handy but ensure that the form is set to Flow content rather than position content.

If you are just starting with Designer JP Terry's book on using LiveCycle Designer is a good start and has a section on this topic. The recent eSeminar may also be helpful.
Hi R_Boyd,

Thank u verry much for the reply. I will try this after lunch! And thank for the tips. I want to know more about this so i will check out your suggestions!

Cheers,

Roy
Rkorpel
Registered: Mar 25 2008
Posts: 12
Well, it works great! Men, i am happy! U made my day!

But, can i add a reset option to in those lines here?

Couse i am show/hide some fields with a calcelation on it. When they field is hidden, is it possible that the information in that hidden field is reset?

Thx sofar! :D
beachbumbali11
Registered: Mar 5 2008
Posts: 74
if you want it to reset then a sugesstion would be to use the Instance mangager
since this will actually create and remove those fields each time it is clicked so they will actually be created again.
Wrap them in a subform with repeat max count set to 1
change event javascript

if (Checkbox.rawValue == 1)
{
_yourSubform.setInstances(1);

}else {
_Flight.setInstances(0);

}
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Another thing to consider is the values for the presence property...

Setting an object to be "hidden" not only makes it invisible, but also removes it from the layout of your form. So if the object in question is part of a flowable subform, or if it is a part of some layout that can readjust based on content, then making it "hidden" will change the look and feel of your form.

Using the presence="invisible" makes the object disappear, but it continues to take up real estate on the form.

I would also caution against using the form:ready event. If you are creating a PDF form and you just want the presence setting action to occur immediately before the form loads in Acrobat/Reader, then I would use DocReady instead. DocReady is actually the last event that fires before the form loads in those apps.

Hope that is of value.

Check out the following Help topics for more info:

Event timing before a form loads:
Scripting > Scripting Using LiveCycle Designer ES > Events > Process eventsPresence property and it's values:
Scripting > Scripting Reference > Scripting Properties > presenceBoth are available in the Designer Help available from within the software (hit F1 when Designer is running).

- Alex
AlScott
Registered: Nov 2 2007
Posts: 123
OK - Now I'm probably being v.thick here - but I can't get it to work. What I've done is this.
Created a blank project. On which I've got a textfield (textfield1), and a checkbox (CheckBox1).

So - I've tried two scripts - one :
if ($.rawValue == 1) then
textbox1.presence = "visible"
else
textbox1.presence = "hidden"
endif

With the type 'Show Enter), and as an Exit event.
No -joy :(
What have I done wrong?? (LiveCycle Designer 8).
thanks
Al
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hi there,

I might be taking your script example too literally, but should it be:

if ($.rawValue == 1) then
textfield1.presence = "visible"
else
textfield1.presence = "hidden"
endif

In other words, the field referenced should not be "textbox".

In any event, another consideration is where you have placed the script. I would have chosen the change event for Checkbox1, with the intent that every time the user selects or deselects the checkbox, the field appears and disappears.

The caveat is that putting this script on that event means that you still have to take care of the initial case (when the form first displays in Acrobat/Reader. To get around that, you could put a simple script on the DocReady event:

textfield1.presence = "hidden"

Assuming you want the field to be hidden until the check box is selected.

Hope that helps.

P.S. Also double check that the form is saved as dynamic pdf, or if you are just previewing it, that you have set the preview to show a dynamic form. You can verify the latter in File > Form Properties and then select the Preview tab.
AlScott
Registered: Nov 2 2007
Posts: 123
Well, it sort of worked. But what happens is this:
If I check the box, nothing happens unless I click anywhere else on the page.
However - let's say when the check box is not selected - I cannot get the text field to re-appear. But if I check the check box, now by clicking anywhere on the page it re-appears.
Basically - selecting 'on' or 'off' using the 'checkbox' doesn't affect the 'textfield' (yes I did name it correctly! :) )
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Did you put the script in the "change" event for the checkbox? The behavior you describe sounds like what would happen if the script was on the "exit" event. In fact, I just tried moving the script to the exit event, and I get exactly what you described.

The change event is the "money" event for things like this. The instant you click in the checkbox, the change event triggers, which is exactly when you want to have the field display/hide (I think).

Exit works, but as you are seeing, it only occurs after a user exits a field, so you have to click away from the checkbox to get the exit event to trigger. The engineers refer to that as "changing the field focus" or just "change the focus".

The other thing you might want to consider is whether the textfield should be showing by default (that is, when the form first loads). In my sample form, I have both the checkbox and textfield showing by default. But to be accurate, if the textfield is showing, really the checkbox should be checked. Alternatively, if the checkbox should be unchecked by default, then the textfield should not be visible.

You can handle this issue in several ways, depending on what you'd like to have happen:

- If you want the textfield to display when the form loads, then just change the default value of the checkbox to "on". You do that in the Value tab of the Object palette.

- If you want the checkbox to be unselected the textfield hidden, then add the following FormCalc script to the DocReady event of the textfield:

textfield1.presence = "hidden"

- Or if you like things the way they are, you just want the script to trigger when the clicking action occurs, then moving the existing script to the change event should set you up.

Hope that helps. Let me know if you need more information.

All the best.
AlScott
Registered: Nov 2 2007
Posts: 123
Yup - that worked. :) So thanks for that. The only snag is that you're always going to get a user who'll check multiple boxes resulting in a very messy screen, (you don't want a form with big gaps between each section - so each version is ostensibly a 'new form' sharing some common sections, but arranged so they're all touching one another.

OK - so you say the obviously the option would be radio buttons, but once again if rather than choose "Form type A" you go for "Form type C" you'll be wanting the "type A" to dissapear and replaced by "type C", then maybe to "type D" if you realize you'd rather use a different form.

But I need a 'radio-button' version............

At 3am I gave up.

Here's my initial script for a 'check-button"

if ($.rawValue == 1) then
form1.#subform[0].SECTION13568.presence = "visible"
else
form1.#subform[0].SECTION13568.presence = "hidden"
endif

Confused Seattle :)
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Seattle? Well there's your problem, you're in Seattle! ;-) I'm only teasing.

Don't be too hasty to assume you have to use radio buttons to solve your particular use-case. While that may be the most intuitive mechanism for your users (you'd be the best judge of that), you could also use scripting to change the rawValue of the checkboxes in response to users selecting or de-selecting them.

You could create some "nested conditions" as the engineers would say. Something along this line ...

Let's say you have 3 checkboxes called CheckBox1, CheckBox2, and CheckBox3, and your subform you want to hide/display. To have only one of them be active at a time, something like the following on the "change" event of CheckBox1 should do the trick:

if ($.rawValue == 1) then
CheckBox2.rawValue = 0
CheckBox3.rawValue = 0
form1.#subform[0].SECTION13568.presence = "visible"
else
form1.#subform[0].SECTION13568.presence = "hidden"
endif

You'd have to add a similar script to the change event of CheckBox2 and CheckBox3, adjusting the names of the checkbox fields referenced in the first "if" statement accordingly.

You can move to radio buttons, which will control the "only one active at a time" problem. Radio buttons are kept in a "group", and unlike checkboxes will have a rawValue between 1 and the number of radio buttons in the group. So a group of three radio buttons will have rawValues between 1 and 3.

Your original script will still work, the "if" statement just needs to be changed for each radio button to account for what the rawValue will be. So on the first radio button it would be:

if ($.rawValue == 1) then
form1.#subform[0].SECTION13568.presence = "visible"
else
form1.#subform[0].SECTION13568.presence = "hidden"
endif

But then on the second radio button it would be:

if ($.rawValue == 2) then
form1.#subform[0].SECTION13568.presence = "visible"
else
form1.#subform[0].SECTION13568.presence = "hidden"
endif

And so on. Again these scripts would be on the change event for each radio button.

I hope that makes sense. Give it a shot, whichever way you decide, and let me know if it doesn't work.

All the best,
Alex (Ottawa, ON, Canada)
AlScott
Registered: Nov 2 2007
Posts: 123
Well I'm a Londoner imported to the US I know expect a little more deference from a Commonwealth citizen :)

I haven't tried your version, but I did get a 'dirty' script to work - Shall definitely give yours a look-see though.

Here's my script (this was for each option):

if ($.rawValue == 1) then
form1.#subform[0].SECTION145678.presence = "visible"
form1.#subform[0].SECTION13568.presence = "hidden"
form1.#subform[0].SECTION134568.presence = "hidden"
form1.#subform[0].SECTION12678.presence = "hidden"
form1.#subform[0].SECTION138.presence = "hidden"
else
form1.#subform[0].SECTION145678.presence = "visible"
endif

With an appropriate version for each 'SECTION'
Al
gdesrosiers
Registered: Jan 21 2008
Posts: 33
I am trying to use one of the solutions above to hide a field when the checkbox has been checked. But when you click the box nothing happens. I have made sure the form is set to dynamic. Here is the formula I am using:

if($.rawValue==1){TextField1.presence="hidden"}{TextField1.presence="visible"}

Is this correct? Obviously I am doing something wrong. Please help.

Also If I were to set two checkboxes to Global and link them would the action I want above still be able to work?

Going Crazy
gdesrosiers
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hi there,

I'm not 100% sure, but I think you aremixing the syntaxes for FormCalc and JavaScript. If you want FormCalc, try this:

if($.rawValue==1)
TextField1.presence="hidden"
else
TextField1.presence="visible"
endif

of JavaScript:

if(this.rawValue==1)
{
TextField1.presence="hidden";
} else {
TextField1.presence="visible";
}

Let me know how it goes.

- Alex
vcurran26
Registered: Nov 6 2008
Posts: 31
This thread has been incredibly useful - thanks!

However, almitche remarked:
The other thing you might want to consider is whether the textfield should be showing by default (that is, when the form first loads).

I want to hide some of the subforms when the form first loads to force the users to select a checkbox and display the correct subforms. I have now learned how to hide subforms when a checkbox is clicked using a script on change. I found an event called initialize - is that where I would set up which subforms display on opening?

if(SubformHdr.CheckBoxNew == 0, SubformHdr.CheckBoxRemove == 0)
{
SubformNew.presence = "hidden";
SubformAddAuth.presence = "hidden";
SubformRemove.presence = "hidden";
SubformCompl.presence = "visible";
}

Am I placing the script in the correct location?
Can I place two conditions on the "if" statement?
When you use "if", do you always need to use "else"?
Thanks,
VC
(Windows, LiveCycle 8)
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hey VC,

You could use the initialize event, but for a standard PDF the form:ready event is more efficient. The initialize event can trigger many times, whereas form:ready only triggers once right before the PDF is displayed to a user.

As for the use of the if statement, for JavaScript (which is what I think you are using):

if((SubformHdr.CheckBoxNew == 0) && (SubformHdr.CheckBoxRemove == 0))
{

}

That would be the more correct syntax (I think). You don't have to use an else statement with the if, but you could ...

if((SubformHdr.CheckBoxNew == 0) && (SubformHdr.CheckBoxRemove == 0))
{
SubformNew.presence = "hidden";
SubformAddAuth.presence = "hidden";
SubformRemove.presence = "hidden";
SubformCompl.presence = "visible";
} else {

SubformNew.presence = "visible";
SubformAddAuth.presence = "visible";
SubformRemove.presence = "visible";
SubformCompl.presence = "hidden";
}

That might only really be useful if you put the script on the click event of a button, and you want the user to be able to toggle the values back and forth.
vcurran26
Registered: Nov 6 2008
Posts: 31
Yi-Haa!!!
It worked, after I corrected the location of the subform and got all the parentheses correct.
Thanks again!
vcurran26
Registered: Nov 6 2008
Posts: 31
The solution almitche helped me develop worked beautifully for the initial display of the form. However, the users save the completed form and pass it on for approval. Everytime the form is opened, it collapses down to the initial view and the input data is lost.
I placed the display script on the form:ready event. There are other events, like preSubmit, and docClose - can they be used to retain the completed form and override the initial display settings?

Thanks, VC
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hey again VC,

Something that might work ... you could encase the existing If statements in another set of if statements that checks to see if the fields on the form contain data. If they do, then you could prevent the visibility changes from happening.

if(someField.rawValue == null) {

// This is the first time the form has been opened, so adjust the presence values

} else {

// The form has been opened, so don't have any scripting to manipulate the presence values of subforms

}

Would that work?

In this case, someField is just a field on the form that you would be sure had data in it IF the form had previously been opened and filled out.

Would that work (and does it make sense to you)?

- Alex
vcurran26
Registered: Nov 6 2008
Posts: 31
Thanks for your response. It makes sense, so I filled out a form to see what happens when a form is saved. The checkboxes at the top stay checked so I use them to determine if the form has been filled out. Did I mention I'm new at scripting?
I look for a check in either checkbox, displaying the correct subform retains the input data.

if (SubformHdr.Table3.Row1.CheckBoxNew.rawValue == 1)
{
SubformHdr.presence = "visible";
SubformNew.presence = "visible";
SubformRemove.presence = "hidden";
}else
if (SubformHdr.Table3.Row1.CheckBoxRemove.rawValue == 1)
{
SubformHdr.presence = "visible";
SubformNew.presence = "hidden";
SubformRemove.presence = "visible";
}else
if((SubformHdr.Table3.Row1.CheckBoxNew.rawValue == 0)&&(SubformHdr.Table3.Row1.CheckBoxRemove.rawValue == 0))
{
SubformHdr.presence = "visible";
SubformNew.presence = "hidden";
SubformRemove.presence = "hidden";
}

However, now if both checkboxes are blank, the subforms are not hidden. Is this because of the chain of "else" statements?
Thanks, VC
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hi VC,

I tried rewriting what you have just to see if I could simplify ... it seems like no matter what, you want the SubforHdr.presence to equal "visible", so I called that out right at the beginning:


SubformHdr.presence = "visible";

if ((SubformHdr.Table3.Row1.CheckBoxNew.rawValue == 0) && (SubformHdr.Table3.Row1.CheckBoxRemove.rawValue == 0))
{
SubformNew.presence = "hidden";
SubformRemove.presence = "hidden";
} else {
if (SubformHdr.Table3.Row1.CheckBoxNew.rawValue == 1)
{
SubformNew.presence = "visible";
SubformRemove.presence = "hidden";
} else {
SubformNew.presence = "hidden";
SubformRemove.presence = "visible";
}
}

So basically ... first check to see if both checkboxes are equal to zero. Then, if that condition doesn't apply then one of the checkboxes must be equal to something other than zero ;-) So then I test one of the checkboxes to see if it equals 1, if it doesn't then obviously the other checkbox equals one.

I am certainly not a expert, and you could argue that my syntax is not the most clear.

However, the code changes should not change the fact that if both checkboxes are de-selected, SubformNew and SubformRemove won't display. The state of those checkboxes should be getting saved when the form is saved ... did you set default values for those checkboxes somewhere else? Or possibly have a script that overrides the checkbox values in any way?

- Alex
vcurran26
Registered: Nov 6 2008
Posts: 31
This problems has been resolved by changing the check boxes to radio buttons, setting the radio buttons to "New" being checked by default, and defining the base subform to display the correct subforms for New when the form displays.
The form can be saved and will display the input information when re-opened.
Thanks for all your help!
VC
techdef
Registered: Jan 11 2009
Posts: 1
This has been a very helpful thread to another newB.

I'm trying to achieve a very similar thing, but I'd like to do with a drop-down list rather than radio buttons.
I've got the code from this thread running in a sample file with radio-buttons, but somehow it just doesnt translate over to drop-down list? It seems like the first thing I drop to has no effect, then the effect is almost random after that. Any thoughts on what would be different?

thanks,
-jamie
vcurran26
Registered: Nov 6 2008
Posts: 31
There was another forum that talked this one through:
Display selected subforms depending on Drop Down Menu at
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=15302

Hope that helps! VC
vcurran26
Registered: Nov 6 2008
Posts: 31
I'm back . . .
My form displays correctly upon opening, but not when saved if the non-default checkbox was checked. I have this in the Base ready:form event:
----- form1.Base::ready:form - (JavaScript, client) ------------------------------------------------

if (Base.SubformHdr.Table3.Row1.RB.RadioButtonList.New.rawValue==1)
{
Base.SubformNew.presence = "visible";
Base.SubformAddAuth.presence = "visible";
Base.SubformRemove.presence = "hidden";
Base.SubformCompl.presence = "visible";
}

The initial form display and the radio button click event work correctly. However, if the Remove radio button is checked and the form is submitted, it opens with the Remove button checked but the subform displayed is not the Remove subform.

I added something similar to the postSave event but that didn't help. Is there a better event for a script to display the correct subforms when the non-default radio button is checked?
Thanks, VC
ASC-David
Registered: Jun 25 2009
Posts: 6
Sorry to dig up an old thread, but I'm not able to get this to work. Here's my dilemma:

Using FormCalc, I have 4 check boxes:

CheckBox1
CheckBox2
CheckBox3
CheckBox4

I would like, on initialization of the form, for only CheckBox1 to be enterable, while the other 3 or locked/greyed out.

Upon checking CheckBox1, I would like to make CheckBox2 unlocked, and enterable. And if CheckBox2 is checked, then that makes CheckBox3 unlocked and enterable. And then the same for CheckBox4.

Conversely, I'd like to reverse the process if any of the previous check boxes are unchecked (So if I uncheck Box1, then that removes any values from boxes 2-4, and then greys them out). Basically, I'm trying to make the form idiot-proof, so the user can't enter a value unless a previous value has been entered.

I'm having a very hard time getting this to function. Which "Event" should I code this under... "Click?"... "Initialize?"

Any help would be appreciated.
scderacjor
Registered: Mar 27 2009
Posts: 123
ASC-David

Consider this option. It's what I've been resorting to when I can't figure on the other features:
Initially, only Checkbox1 appears. When it is selected, Checkbox2 appears, and the pattern continues. If that sounds like it would work for your purpose, try this if/else code:

if (CheckBox1.rawValue == true)
CheckBox2.rawValue = "On";
else
CheckBox2.rawValue = "Off";
NickDB
Registered: Aug 17 2009
Posts: 1
Hi
I'm a new user I have managed to get some info on calculating the difference between two fields
"ALFirstDay" & "ALLastDay" and put the result in field "TotalAL"
I would like to have the colour change for field "TotalAL" if "ALFirstDay" is blank but this script is not working.

Can someone please assist?
See script below

Thanks, Nick



// document level function get floor value of a number
function Floor(fValue) {return Math.floor(fValue);} // end Floor function

// document level function to compute the number of days from the Epoch date
function Date2Num(sDate, sFormat) {var fSecond =1000;
var fMinute = 60 * fSecond;
var fHour = 60 * fMinute;
var fDay = 24 * fHour;

var oDate = util.scand(sFormat, sDate); // convert string date to date time object
var fDate = oDate.valueOf(); // convert to milliseconds from epoch date;
var fDate = fDate / fDay; // milliseconds convert to days
var fDate = Floor(fDate); // convert to lowest whole number
return fDate; // return number of days
} // end Date2Num function

// custom filed calculation to compute the difference in days between 2 dates
// compute difference in minutes and convert to days
var Start = this.getField("ALFirstDay").value; // start date value
var sFormat = "dd/mmm/yyyy"; // start date format
var End = this.getField("ALLastDay").value;

var sFormat = "dd/mmm/yyyy"; // end date value
var eFormat = sFormat; // end date format
event.value = Date2Num(End, eFormat) - Date2Num(Start, sFormat);

if ("ALFirstDay".value == 0)
"TotalAL".target.textColor=color.blue;
else
"TotalAL".target.textColor=color.red;
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
@NickDB

You post is very off-topic here, this thread is for LiveCycle forms, not AcroForms.
Please open a new thread under JavaScript.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

hughstawski (not verified)
ASC-David wrote:
Sorry to dig up an old thread, but I'm not able to get this to work. Here's my dilemma:Using FormCalc, I have 4 check boxes:

CheckBox1
CheckBox2
CheckBox3
CheckBox4

I would like, on initialization of the form, for only CheckBox1 to be enterable, while the other 3 or locked/greyed out.

Upon checking CheckBox1, I would like to make CheckBox2 unlocked, and enterable. And if CheckBox2 is checked, then that makes CheckBox3 unlocked and enterable. And then the same for CheckBox4.

Conversely, I'd like to reverse the process if any of the previous check boxes are unchecked (So if I uncheck Box1, then that removes any values from boxes 2-4, and then greys them out). Basically, I'm trying to make the form idiot-proof, so the user can't enter a value unless a previous value has been entered.

I'm having a very hard time getting this to function. Which "Event" should I code this under... "Click?"... "Initialize?"

Any help would be appreciated.
I am having the same problem
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Ok,

to control the access property of a checkbox anytime you work with a form, the only event that is handy for this is the calculate event.
Therefore you need a extra field, that's doing the calculation.
That's because a field that uses a script in the calculate event is automatically write protected.

So, a simple example from me:
1. Create 4 checkboxes (CheckBox 1 to 4)
2. Create 3 invisible textfields (TriggerCheckBox2 to 4) and put it next to the regarding checkbox.
3. Add the following script to the first textfield
if (CheckBox1.rawValue == 0) thenCheckBox2.rawValue = 0 //set this value to 0 if the previous checkbox is also nullCheckBox2.access = "protected" //protect checkboxCheckBox2.caption.value.text = "not available" //change caption to "not available"CheckBox2.caption.font.fill.color.value = "255,0,0," //change caption color to redelseCheckBox2.rawValue = CheckBox2.rawValue //keep the current valueCheckBox2.access = "open" //open checkboxCheckBox2.caption.value.text = "available" //change caption to "available"CheckBox2.caption.font.fill.color.value = "0,0,0," //change caption color to blackendif

4. Repeat step 3 for the following textfields

https://share.acrobat.com/adc/document.do?docid=c833e2e9-a567-49e9-baec-6225e64b495b

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jdrkookie
Registered: Sep 3 2009
Posts: 1
I'm trying to accomplish the same thing in Adobe Acrobat Professional...

I have a SalesTax Field applicable to only one State. I want to provide a check box that hides the SalesTax field if not applicable, and when checked to show the SalesTax field... Please advise...
John Grand
Registered: Aug 18 2009
Posts: 18
looking for a basic check box example or sample form.

I have a form that includes two subforms. I want to use a check box make one of the sub form visible or invisible. I have tried various methods but no luck. My last method was placed in the check box1 change using form calc.

if($.rawValue==1)
{subform1.presence="visible",}
elseif($.rawValue==0)
{Subform1.presence="invisibe",}

The Error is:

Error:accessor'$.rawValue' is unknown

Any help would be appreciated ...... John
dk3dknight
Registered: Jan 22 2008
Posts: 136
http://docs.google.com/fileview?id=0B-drzn5llddGZjM4YzVjNTEtZjVkYi00YTI1LWJmOTktOTlkNTZlMzBmNTYx&hl=enOkay I got a basic form created im uploading it to google doc so you can download and look at the code.. im using something a little drastic myself heres a show of the code for the form.

//this is a click event on one of the checkboxes
TextField1=TextField1*-1

//btw remeber to set the default value for your textfield to be 1,
//what happens here is when you multiply a negative number by
//by a positive number it becomes negative but when you multiply
//a negative by a negative it becomes positive thus creating a switch
//allowing the reappearance of the page

if (TextField1==-1) then
form1.Magic2.presence="hidden"
elseif (TextField1==1) then
form1.Magic2.presence="visible"
endif

//Very important that you pick hidden invisible only vanishes
//the contents not the physical page, hidden hides the page
//when the user clicks again it is rerevealed.

I hope this helps you.


Oh and if you need a direct download here it is...
http://docs.google.com/uc?export=download&id=0B-drzn5llddGZjM4YzVjNTEtZjVkYi00YTI1LWJmOTktOTlkNTZlMzBmNTYx
John Grand
Registered: Aug 18 2009
Posts: 18
Worked Great Thank You
dk3dknight
Registered: Jan 22 2008
Posts: 136
Funny thing I have to thank you in this instance, by helping you I discovered how to do it.
johnmolina
Registered: Mar 27 2008
Posts: 76
Thanks for this thread!!!

had wrong syntax for javascript and had it set as static.

Have only used LiveCycle for a couple of forms and this forum is tops!!!
rcwip
Registered: Oct 30 2010
Posts: 13
I tried to use checkbox1 to show and hide the textfield1 but to no avail. I used the following script as you advised above.

I used Formcalc: ( form1.#subform[0].CheckBox1::change - (FormCalc, client)

)

if ($.rawValue==1)then
TextField1.presence="visible"
else
TextField1.presence="hidden"
endif

and for TextField1 ( form1.#subform[0].TextField1::docReady - (FormCalc, client):

TextField1.presence="hidden"

When I set to preview, the Checkbox1 can be select but the TextField1 can never be shown! I have also set preview to dynamic one. What did I miss?

Cheers
Raymond