开发者

Add a javascript value to a Freemarker list

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 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 coming from server code.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜