如何传递< @ spring.formSingleSelect ..>的值到javascript?

时间:2015-02-24 18:28:59

标签: freemarker

如何将表单选择值传递给js函数

<script type="text/javascript">

function myfunction(var id){
    alert("hi"+id);
}

<@spring.formSingleSelect  path="LoginIDForm.ID"  options=userIDs    attributes='onChange="myfunction();"'/>

1 个答案:

答案 0 :(得分:1)

我相信这会奏效:

<@spring.bind path="LoginIDForm.ID" />

<script type="text/javascript">
    function myfunction(var id){
        alert("hi" + id);
    }
</script>

<@spring.formSingleSelect path="LoginIDForm.ID" options=userIDs 
    attributes='onChange="myfunction(\'${spring.status.expression}\');"'/>

基本上<@spring.formSingleSelect path="LoginIDForm.ID" />是做的简写:

<@spring.bind path="LoginIDForm.ID" />
<select name="${spring.status.expression}">

</select>

${spring.status.expression}拥有您需要的价值。