Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

execute javascript function from jstl <c:if>

Posted on 2015-02-07
3
Medium Priority
?
3,519 Views
Last Modified: 2015-02-08
javascript function is not executing;
getDimentions() is in external javascript file and it is included in jsp file <head></head> tag.

Here is jsp code:

<div>
<c:if test='${not empty dimValues}'>
<script type="text/javascript">
  getDimensions('<%=cubeValue%>');
 </script>
  </c:if>
</div>

Open in new window


Here is javascript code :

function getDimensions(dim1)
{
	document.write(dim1);
	
}

Open in new window

0
Comment
Question by:Pradip Shenolkar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
rrz earned 2000 total points
ID: 40596502
If you want people to help you, then you should make it easy for them to do so. You should post small(minimal) code that is complete. That way people can copy and paste to test.  Please try running the following code.  
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%
   String cubeValue = "six sides";
   pageContext.setAttribute("dimValues", "6");
%>
<html>
<head>
    <title>Testing</title>
    <script type="text/javascript">
        function getDimensions(dim1)
        {
	        document.write(dim1);
        }
    </script>
</head>
<body>
    <div>
    <c:if test='${not empty dimValues}'>
        <script type="text/javascript">
             getDimensions('<%=cubeValue%>');
        </script>
    </c:if>
    </div>
</body>
</html>

Open in new window

0
 

Author Comment

by:Pradip Shenolkar
ID: 40596841
Ok. Hence I'll try to send code in proper format.
I solved the problem.
0
 

Author Closing Comment

by:Pradip Shenolkar
ID: 40596844
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question