?
Solved

execute javascript function from jstl <c:if>

Posted on 2015-02-07
3
Medium Priority
?
3,230 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

770 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