Expand my Community achievements bar.

Changing Variable values and saving it across sessions.

Avatar

Former Community Member

Hi,

I've have an requirement like counting the number of times a form is opened and number of times a button is clicked.For this I tried to use global variables.I tried to increment the value of the variable each time a form is opened or a button is clicked.

opencount.value += 1;

But it didnt work for me.I tried to hardcode a value like

opencount.value = 5;

Even this is also not working.Do I need change any settings or extend rights.Is it possible to save the values that are persistent across the sessions.

Please help

5 Replies

Avatar

Level 10

Hi,

Have a look at using the <desc> element here: http://assure.ly/x1QObn. It is preserved across sessions.

Niall

Avatar

Former Community Member

Hi,

Thanks for the reply.I dont think the state is maintained here.Once the form is closed and reopened the <desc> element got reset to original state (null).

I want the state of an object to be maintained.I cant expect the user to save a form.

Avatar

Level 10

Hi, can't test now - will have a look tomorrow. Niall

Avatar

Level 10

Hi,

I have checked the above example above and it does preserve the variable attached to the <desc> element. In your form, make sure that in the File > Form Properties > Defaults tab that the Preserve Script Changes is set to Automatic.

Hope that helps,

Niall

Avatar

Level 10

I have another apporach using an extras object.

What you is a script object 'Actions' with this script, to create a counter in the extras object in any form object.

Then you need another script, to call the function in the script object and raise the counter, when the form opens.

I used a floating field in a text on a master pager and put this script into its initialize event.

Here's a sample form with an open and save counter.

https://acrobat.com/#d=C90OHrJKx52LHrtbtahWzQ