最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Add a javascript value to a Freemarker list - Stack Overflow

programmeradmin2浏览0评论

I need to add values from a javascript function to a freemarker list

Example : I pass from my controller to the view an object,schoolObject. schoolObject has a List attribute called classNames

Is it applicable to add values to this list from a javascript !!

The following doesn't work :

function addclass(className){ 
    var name=document.getElementById(smth).value.trim();
    document.getElementById(classNames).value=name
    alert(document.getElementById(classNames).value);
  }

I need to add values from a javascript function to a freemarker list

Example : I pass from my controller to the view an object,schoolObject. schoolObject has a List attribute called classNames

Is it applicable to add values to this list from a javascript !!

The following doesn't work :

function addclass(className){ 
    var name=document.getElementById(smth).value.trim();
    document.getElementById(classNames).value=name
    alert(document.getElementById(classNames).value);
  }
Share Improve this question asked Aug 9, 2011 at 15:47 EchoEcho 3,04915 gold badges54 silver badges65 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

I think you misunderstand the goal of freemarker and javascript.

Javascript is a client language. It allows you to add dynamic behavior on a page which is already rendered by the server.

Freemarker is a template language which allows you to format an html page on the server before it is rendered.

So, you can't fill a freemarker list with javascript but you can fill this list with a list ing from server code.

Once the page is rendered to the client, freemarker is not used anymore, only your javascript is used...

发布评论

评论列表(0)

  1. 暂无评论