Calling Javascript Code from a Button

Running Javascript code when a button is clicked is straightforward with Iron Speed Designer using the pass-through attribute mechanism on the button’s Properties dialog.

Select Tools, Properties... to open the Properties dialog.  Then, select the appropriate button control and go to the Attributes tab to add a new attribute 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:

Pass-Through Attribute

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:

Pass-Through Attribute

Value

onMouseMove

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

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:

Pass-Through Attribute

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:

Pass-Through Attribute

Value

onClick

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

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:

Pass-Through Attribute

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:

Pass-Through Attribute

Value

onClick

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

onMouseMove

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

onMouseOut

javascript:window.status=' '

Caveats

Ensure that JavaScript is enabled in your web browser.

See Also

Button Actions and Properties

Button Display Properties

Button Binding Properties

Button Bindings - Redirect and Send Email Actions

Button Bindings - Substitution Variables

Button Tag Pass-Through Attributes