如何使用 spring 表单标签在 onchange 事件中调用 javascript 函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6847324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call javascript function in onchange event with spring form tag?
提问by aman.nepid
I have a showCustomersList()
javascript function in FunctionBag.js
now I want to call that function in onchange event of the springs <form:select onchange="">
tag in a jsp file.
我现在有一个showCustomersList()
javascript 函数,FunctionBag.js
我想<form:select onchange="">
在 jsp 文件中springs标记的onchange 事件中调用该函数。
How can I do that?
我怎样才能做到这一点?
回答by soufell
This is how we do it in 2011. use Jquery
这就是我们在 2011 年的做法。使用 Jquery
$('#yourFormId select').change(function() {
showCustomersList();
});
回答by Johnny Craig
This should work
这应该工作
<form:select onchange="javascript:showCustomersList();">
<form:select onchange="javascript:showCustomersList();">