Eme Emertana
Eme Emertana

Reputation: 571

Struts button - How to prevent page refresh onclick event?

I am using following code:

<s:submit type="input" value="clickme" onclick="func()"/>

and in func() I have an alert("hereee") but when I click it, it shows "hereee" in an alert window. But it also refreshes the page as well. How to prevent page refresh onclick event?

Can anyone help?

Upvotes: 0

Views: 2220

Answers (1)

Ahsan Khurshid
Ahsan Khurshid

Reputation: 9469

Use return false to prevent the page refresh.

<s:submit type="input" value="clickme" onclick="func(); return false;"/>

See Demo

Upvotes: 1

Related Questions