Skip to content

APEX: Save a user’s checkbox selection on local PC

August 14, 2014

You want a checkbox item on a page which is a preference, you want it to be remembered for the user across login sessions, but you don’t want the overhead of storing it in a database table. You might choose to store the value in a cookie instead. It may be lost (e.g. when the user clears their cookies or changes to a different browser or another computer), but we don’t mind – it’s just a preference.


1. Create checkbox item, e.g. P1_STAY_ON_PAGE

Display As = Checkbox
Template = No Label
List of values definition = STATIC2:Stay on page;Y

2. Add dynamic action to the checkbox item to save it when it’s changed

Event = Change
Selection Type = Item(s)
Item(s) = P1_STAY_ON_PAGE
Condition = (none)
True Action = Execute JavaScript Code
Fire On Page Load = (No)
Code = SetCookie("APEX_P1_STAY_ON_PAGE",$v("P1_STAY_ON_PAGE"));

3. Add dynamic action on page load to load it

Event = Page Load
True Action = Execute JavaScript Code
Code = $s("P1_STAY_ON_PAGE",GetCookie("APEX_P1_STAY_ON_PAGE"));

Note that the cookie name (“APEX_P1_STAY_ON_PAGE” in this example) is up to you to choose. Probably best to try making it specific to your application so it doesn’t clash with anything else.

From → APEX

  1. praganitsch permalink

    You might want to consider looking at localStorage as an alternative to Cookies. Cookies are being sent to the server with each http-request, localStorage is in the browser only.

  2. Tom permalink

    I would also like to point out that, if you do want to use cookies, you should use (
    The old “GetCookie” and “SetCookie” are functions in the legacy.js file and are tagged deprecated.

Comments are closed.


Get every new post delivered to your Inbox.

Join 271 other followers

%d bloggers like this: