如何将表单选择值传递给js函数
<script type="text/javascript">
function myfunction(var id){
alert("hi"+id);
}
<@spring.formSingleSelect path="LoginIDForm.ID" options=userIDs attributes='onChange="myfunction();"'/>
答案 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}
拥有您需要的价值。