Call javascript function with if JSTL

David picture David · Jan 13, 2015 · Viewed 17k times · Source

Is there a way to call a javascript function inside an if with JSTL?

Here's the code

<c:choose>
                <c:when test="${orderUploadAction.errors.size()==0}">

                CALL JS FUNCTION HERE

                </c:when>
                <c:otherwise>

                CALL JS FUNCTION HERE

                </c:otherwise>
</c:choose>

Answer

Oleksandr T. picture Oleksandr T. · Jan 13, 2015

Try this

<c:choose>
  <c:when test="${orderUploadAction.errors.size()==0}">
     <script> yourFunctionName() </script>
  </c:when>
  <c:otherwise>
     <script> yourAnotherFunctionName() </script>
  </c:otherwise>
</c:choose>