Expand my Community achievements bar.

Setting a Check Box presence to invisible

Avatar

Level 2

Hello all,

Okay so I have a form that will be filled out, saved unlock, then saved locked.

With this I mean that I have two buttons on the form, one that says "save unlocked" which when clicked, it will simply execute the "save as" menu item.  Now for the button that says, "save locked", it locks all of the fields on the form so that they cannot be edited anymore and makes the two saving buttons presence to invisible.

Where here is my problem, when i first added the buttons and script and all, I did not have any Check Boxes.  I have now added two check boxes that need to be shown from when the form is opened, "saved unlocked", and up untill the "save locked" button is clicked.

The script for the "save unlocked" button is the following:


form1.Page1.Button2::click - (JavaScript, client)

myScriptObject.LockAllFields(form1);

Button1.presence = "invisible";
Button2.presence = "invisible";


app.execMenuItem("SaveAs");

Button1 and Button2 are the saving buttons I listed above.

Now when I add the following script to it, the Check Boxes do not go invisible like the buttons do when I click the "Save Locked" button.

form1.Page1.Button2::click - (JavaScript, client)


myScriptObject.LockAllFields(form1);


Button1.presence = "invisible";
Button2.presence = "invisible";

CheckBox1.presence = "invisible";

CheckBox2.presence = "invisible";


app.execMenuItem("SaveAs");

Is there something stupid easy that I am overlooking?

Thanks in advanced!!!

-HKSevo8

8 Replies

Avatar

Level 2

I have tried the following added to the script on the click event of the "save locked" button

if(this.form1.Page1.CheckBox1.presence == "visible")
    this.form1.Page1.CheckBox1.presence = "invisible";

and all it does is make the check invisible if it is checked before the save....but the caption and the actual check box are both still visible.

Avatar

Level 2

Okay well I figured it out.  Was something easy like I figured.  I was saving the form as a static pdf and not a dynamic pdf.

BUT NOW another problem arises.  Some of my fields (user required) now have a thick red box around them, that stays there even when saved. Before, it had a thinner red box which did not stay when saved.

Any ideas?

Avatar

Level 2

Well let's see. First I would have to say that making the save buttons to "hidden" would be better than just invisible. Hidden

basically makes it so that they will no longer exist on the form (for the user).

What you'll want to check with the red box is if you have those fields as "Required" in the options for the object. If it's "Required" then there will be a red box. As for why it's now thicker, I also ran into this problem and found that it's easier just to get rid of the borders. I never got the chance to check that solution because I decided that it would be easier just not to have required fields.

I hope this helps.

Edit- Oh I forgot to say, in general you want to save your forms as Dynamic PDFs because otherwise, you won't be able to do anything interesting. This is usually not an issue with a normal form but if you have any dynamic elements, it's generally what you'll want to be doing. You can save your settings to automatically make all of your documents Dynamic PDFs when you create them.

Avatar

Level 2

Darknesscalls1,

Thanks for the suggestion.  Yea I havent messed with acrobat in a while, been about a year but now im making another form.  Back then, I saved my pdf's as dynamic.

Saving as dynamic has now solved all of my issues.  I am able to make the fields that I need invisible, invisible.

BUT, now when I click my "save locked" button, the fields lock and go invisible AFTER the form is saved.

Im at complete lost!?!?!

here is the complete code that my button has under the click event:

  form1.Page1.Button2::click - (JavaScript, client)
//Locks all fields
myScriptObject.LockAllFields(form1);


//Sets presence of bottons & check boxes to invisible
Button1.presence = "invisible";
Button2.presence = "invisible";
CheckBox1.presence = "invisible";
CheckBox2.presence = "invisible";


//Sets font color of field to white if default value is present.  Each field is separated by a "break".
if (Contact_Name.rawValue == "Enter Contact Name")
{
xfa.resolveNode("form1.Page1.Contact_Name").font.fill.color.value = "255,255,255";
}
//break
if (Contact_Company.rawValue == "Enter Company Name")
{
xfa.resolveNode("form1.Page1.Contact_Company").font.fill.color.value = "255,255,255";
}
//break
if (AddressLine1.rawValue == "Enter Company Street Address")
{
xfa.resolveNode("form1.Page1.AddressLine1").font.fill.color.value = "255,255,255";
}
//break
if (AddressLine2.rawValue == "Enter Company City/State/ZIP")
{
xfa.resolveNode("form1.Page1.AddressLine2").font.fill.color.value = "255,255,255";
}
//break
if (Contact_PhoneNo.rawValue == "Enter Contact Phone Number")
{
xfa.resolveNode("form1.Page1.Contact_PhoneNo").font.fill.color.value = "255,255,255";
}
//break
if (Scope.rawValue == "Enter Scope of Work here")
{
xfa.resolveNode("form1.Page1.Scope").font.fill.color.value = "255,255,255";
}


//Executes the "Save As" menu item
app.execMenuItem("SaveAs");

I know my script doesnt look the best but im no near a pro at java script hahaha

Any help will be appreciated!!!

Message was edited by: HKSevo8

Avatar

Level 2

Try isolating the problem. You should put everything into quotes except for  the line

that locks everything. See if that works and continue.

If I remember correctly, you can do an extended comment by putting

/*

This text is now commented etc.

*/

Everything between the two slashes and asterisks should be commented. Narrow it down and slowly introduce more things (by taking them out of the comment) until you find the bit that's screwing it up. I hope that this helps.

It would be funny if it was all disappearing because you're making everything the same color as the background. That's not what you're doing is it? I mean, if you're making everything white (which is what it looks like) and your background is also white...

Edit - Alright, so I looked at it again and I'm pretty sure that your script isn't checking it correctly. LC is picky about the syntax so there's a good chance that it's not happy checking the string. What I would do (and usually do) is set up a bunch of variables. Now normally, you can't carry variables over but what I do is make numeric fields that are hidden and place them at the top of the form while making their default value "0". Then in the "Change" event of your text fields, put your form's version of this:

HiddenField1 = 1;

Then, instead of checking for the string, just go

if (HiddenField1 == 0)

{

Make it white

}

The first bit will make it so that (hopefully) when you change the value of your text field, it makes your variable "1". You then check to see if the hidden field is still "0", if it is then you make it white. Try doing this for one of your fields so you'll be able to see if the problem is with how you're referencing your text field or if the issue is checking the string.

I hope this helps too.

Edit 2 - So I've thought about it again. Another issue that you could look into is to see if you're referring to the field correctly because LC is picky about that too. What you should do to test this (and it's quick) is to click in your script window at the top of the page, then press and hold "Control", and click on the field you''re referring to. You'll find that LC will make a path to that field for you. If it matches what you have then you're fine. If it's different at all, replace the version of the name you have there in your code with the one that LC gave you.

Here's an example:

Textfield1.rawValue = 1;

//This is what LiveCycle gives you:

Subform2.Textfield1

Now in that case, it means that the thing you're referring to, Textfield1, is in a different Subform than whatever has the scrpit in it. In that case, it's not good enough just to put the basic name, you also have to pu the name of the Subform that it's in. To be safe, you can also press Shift+Control and click which gives you the full path for your object. The full path should always work when refering to another object in the form.

Avatar

Level 2

The problem as far as I can tell is that the save script is being ran first when it should be last.

And what im doing is if the default value is still in the text field (i.e. the user hasnt changed the text), then it simply puts the default valve as white font which is the background color.  This is only for a small portion of the field.


Not sure what you're meaning by set up a bunch of variables.  Have really messed with variables yet So Im not really sure what to do about that much haha.

Also, everything works fine with turning the fields white, it just does it at the wrong time.  I need the fields to turn white (or go hidden if they say the default) then the "save as" window pops-up.  Versus the "save as" button first popping up then after I save the fields turn white and the buttons/check boxes go invisible (which is what is happening now).  So I dont think it is necessarily a referring issue.  And yeah I already new about the "control" and the "control + shift" shortcut, it surely helps sometimes!

Thanks for the help!!!  I really appreciate it!


Avatar

Level 2

Hmm, yeah I really don't know what to tell you about that. Maybe you can send me the form via email? Send it to sean.yeats@bendix.com and I'll take a look at it.

The code SHOULD be running from top to bottom and I'm not sure why it's not doing that.

Avatar

Level 2

okay im going to email you the form right now.  I really appreciate your time and help!!!!  this thing has been frusterating me hahaha.