Calling JavaScript Code from a Button

Running JavaScript code when a button is clicked is straightforward with Iron Speed Designer using the custom property mechanism.

Step 1:  In Design Mode, select the appropriate button control.

Step 2:  In the Property Sheet, add a new custom property with the appropriate name and value.

The easiest way to understand this mechanism is by example.

Display a message on the browser window status bar

This example displays a message in the browser window status bar as you mouse over a button.

For Theme Buttons such as Save, OK and Cancel at the end of the page:

Custom Property

Value

Button-HtmlAttributes-onMouseMove

javascript:window.status='Press to Save Data...';

Button-HtmlAttributes-onMouseOut

javascript:window.status=' '

For Image buttons such as shown in the button bar:

Group

Property

Value

Events

onMouseMove

javascript:window.status='Press to Save Data...';

Events

onMouseOut

javascript:window.status=' '

Display confirmation message for record deletion

You can display a confirmation dialog when the application user clicks a Delete button.

For Theme Buttons such as Save, OK and Cancel at the end of the page:

Custom Property

Value

Button-HtmlAttributes-onClick

javascript:return confirm("Are you sure?");

Button-HtmlAttributes-onClientClick

OnClientClick is an alternative to OnClick

javascript:return confirm("Are you sure?");

For Image buttons such as shown in the button bar:

Group

Property

Value

Events

onClick

javascript:return confirm("Are you sure?");

Events

onClientClick

OnClientClick is an alternative to OnClick

javascript:return confirm("Are you sure?");

Prompt when a button is clicked

This example displays a message in the browser window status bar as you mouse over a button a displays a confirmation dialog when the button is clicked.

For Theme Buttons such as Save, OK and Cancel at the end of the page:

Custom Property

Value

Button-HtmlAttributes-onClick

javascript:return confirm("Are you sure?");

Button-HtmlAttributes-onMouseMove

javascript:window.status='Press to Close...';

Button-HtmlAttributes-onMouseOut

javascript:window.status=' '

For Image buttons such as shown in the button bar:

Group

Property

Value

Events

onClick

javascript:return confirm("Are you sure?");

Events

onMouseMove

javascript:window.status='Press to Close...';

Events

onMouseOut

javascript:window.status=' '

Caveats

Ensure that JavaScript is enabled in your web browser.

See Also

Button Tag Properties

Button Actions and Properties

Button Actions

Button Actions - Redirect and Send Email Actions

Button Actions - Substitution Variables