onclick - Click Script

Activates an event handler when a mouse click occurs.

Category

events

Syntax

<xp:eventHandler event="onclick" attributes>content</xp:eventHandler>

Usage

For detailed event handler syntax, see eventHandler - Event Handler (property).

Examples

This button has both client and server handlers for the onclick event. The client handler runs first. If the confirm statement returns true (the user responds OK), the server handler runs.
<xp:button value="Click" id="button1">
	<xp:eventHandler event="onclick" submit="true"
		refreshMode="complete">
		<xp:this.action>
			<![CDATA[#{javascript:requestScope.status = "Button clicked"}]]>
		</xp:this.action>
		<xp:this.script>
			<![CDATA[return confirm("Do you want to submit?")]]>
		</xp:this.script>
	</xp:eventHandler>
</xp:button>