VARIABLES

OVERVIEW

Variables in Axure RP are structures used to store alphanumeric information (the variable's "value"). Variable values can then be used in a variety of ways—displayed or manipulated using actions, or moved between pages in the HTML output. Variables must be named, and can optionally be given default starting values.


Use a variable when you want to collect some information, like a name, and then pass it to another page and display it as part of a greeting message. If you want to perform some math on some numbers in your diagram—like to multiply a unit price by a unit quantity, for example—and then display the result, that's another good opportunity to use a variable.


There is no hard limit to the number of variables you can use in a single RP file, but we recommend limiting to 25 or fewer (especially if you are using Internet Explorer to view the prototype).

GLOBAL VARIABLES

Global variables persist across pages, which means you can set a global variable's value on one page and then take action based on that value on another page. (When we talk about "variables" in the context of Axure RP we are generally referring to global variables as opposed to local variables, which have a narrower application and are discussed below.)

MORE RESOURCES

© 2002-2016 Axure Software Solutions, Inc. All rights reserved. Axure ® is a registered trademark of Axure Software Solutions, Inc.

86% OF THE FORTUNE 100

USE AXURE RP

AXURE

RESOURCES

LEGAL

CONNECT

EMAIL

CREATING VARIABLES

View and manage variables in your project using the Global Variables dialog, available from the main menu at "Project > Global Variables...".

 

Every RP file starts with a single global variable—named "OnLoadVariable"—but you can make more. To add a new variable in the Global Variables dialog, click the green "+" button and then type a name. Variable names must begin with a letter, must be alphanumeric (no spaces), and must be 25 characters or fewer.


Rename a variable by doing a slow double-click on the variable name. Reorder variables using the blue "up" and "down" arrows, and delete them using the red "x".


In the right column of the Global Variables dialog, do a slow-double click to set the default value of the variable. It isn't necessary to set a default value, but it can be useful sometimes.

SETTING VARIABLES WITH ACTIONS

The "Set Variable Value" action is available in the Case Editor for when you want to set a variable's value as part of an interaction.


When configuring the "Set Variable Value" action you can either choose from a list of variables already in your file or you can click "Add Variable" to be taken to the Global Variables dialog.


In the dropdown at the bottom of the right-hand column of the Case Editor, choose what your target variable's value will be set to. Choose from the following options:


Value: A value you manually enter or that you define with an expression, by clicking the "fx" button.


Value of variable: The value stored in another variable. Choose from the list of variables or add a new one.


Length of variable value: The length (in number of characters) of another variable value. Choose from the list of variables or add a new one.


Text on widget: The text on a widget, or the text entered into a text field or text area. Choose a target widget from the list.


Text on focused widget: The text on the widget that has focus in the browser at the moment the action is executed.


Length of widget value: The length (in number of characters) of the text on a widget.


Selected option of: The currently selected value of a droplist or list box. Choose a target widget from the list, which includes only the droplist and list box widgets on the page.


Is selected of: Can be either "true" or "false", based on whether a widget is set to its selected state. Choose from a list of selectable widgets on the page.


State of panel: The name of a dynamic panel state. Choose from the list of dynamic panels on the page.

USING VARIABLES IN CONDITIONS

You can define conditions based on variable values. In the Condition Builder dialog, you’ll find two variable-based values you can use: value of variable and length of variable.

LOCAL VARIABLES

Local variables are alphanumeric values which are named, defined, and used within just a single action in a case.

CREATING LOCAL VARIABLES

In an action, you can create a local variable anywhere that you can click the "fx" button to create an expression. They are named, defined, and managed in the "Local Variables" section at the bottom of the "Edit Value" dialog.


You can set a local variable to the following types of values:


Is selected of: Can be either "true" or "false", based on whether a widget is set to its selected state. Choose from a list of selectable widgets on the page.


Selected option of: The currently selected value of a droplist or list box. Choose a target widget from the list, which includes only the droplist and list box widgets on the page.


Value of variable: The value stored in another variable. Choose from the list of variables or add a new one.


Text on widget: The text on a widget, or the text entered into a text field or text area. Choose a target widget from the list.


Text on focused widget: The text on the widget that has focus in the browser at the moment the action is executed.


Widget: The name of a widget. Choose from the widgets on the page. Useful for getting widget size and location.

USING LOCAL VARIABLES

Use a local variable in the expression configured at the top section of the "Edit Value" dialog. Learn about expressions in this article.

Tip: Try to give your variables descriptive names (i.e. "UsernameVar" and "CartTotalVar" vs. "Var1" and "Var2") so that they're easier for you and others working with your file to understand later.