Luis
Luis

Reputation: 341

Struts2 link as button

I was wondering if the struts2 link (<s:a>) could have the same behave of a submit button (<s:submit>)?

Upvotes: 0

Views: 565

Answers (2)

Nirav Prajapati
Nirav Prajapati

Reputation: 3005

    <script type="text/javascript">
        function logout() {
            document.getElementById("form1").action = "checkliveuser?action=logout";
            document.getElementById("form1").submit();
        }
    </script>
.
.
.
other HTML code
.
.
.
<s:form action="chkUser" method="post" id="form1"  >
<s:a onclick="logout();" href="#" >Logout</s:a>

</s:form>

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160321

Sure, if you use JavaScript to submit the form in question.

Upvotes: 4

Related Questions