Shankar
Shankar

Reputation: 11

how can assign a jQuery value to a variable in a ftl file?

I am new to jQuery and ftl. The process I'm trying to achieve is to assign a checkbox value to a ftl variable. In my example the variable selectedValues contains the necessary value which is to be copied into an ftl variable. Passing jQuery values to an ftl variable is possible.

Here is the example code I tried with:

<script type="text/javascript">
$(document).ready(function () 
{
var selectedValues="";
$checkedCheckboxes = $("input:checkbox[name=numbers]:checked");
$checkedCheckboxes.each(function () {
selectedValues +=  $(this).val() +",";
});
alert(selectedValues);
});
</script>

    <#assign checkboxvalue=" ? "/>

Upvotes: 1

Views: 1734

Answers (1)

ŁukaszBachman
ŁukaszBachman

Reputation: 33735

This is not possible, I'm affraid. Freemarker templates are evaluated on the Server side. Java Script is evaluated on the client side.

Upvotes: 2

Related Questions