Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
194
rated 0 times [  196] [ 2]  / answers: 1 / hits: 24750  / 12 Years ago, wed, july 4, 2012, 12:00:00

I have some basic JavaScript function:



<script type=text/javascript>
function someTestFunction(param1, param2) {
//do something
}
</script>


and Freemarker code:



<#if something==somethingElse>
// call: someTestFunction(something, 123)
<#else>
// call: someTestFunction(somethingElse, 345)
</#if>


my question is: Is it possible, and if so, how to call someTestFunction() from inside freemarker tags?


More From » freemarker

 Answers
8

Freemarker is a java templating language, meaning it is executed on the server. javascript is executed on the client (user's browser). You cannot call a javascript function from the java server in this manner.



You could do something like:



<script>
<#if something==somethingElse>
someTestFunction(something, 123);
<#else>
someTestFunction(somethingElse, 345);
</#if>
</script>


which means the javascript wll be executed on the client side depending on what server variable is set.


[#84478] Tuesday, July 3, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruz

Total Points: 415
Total Questions: 98
Total Answers: 109

Location: France
Member since Thu, May 6, 2021
3 Years ago
;