Grails:将两个 g:select 的值添加到 HTML 多选列表
我有两个 g:select 组合框,我想在单击图像时将其添加到多选列表中。
这是 javascript 中的函数:
function addToList(list,firstOpt, secOpt)
{
var y = document.createElement('option');
y.text = firstOpt + ' - ' + secOpt;
y.value = firstOpt+'-'+secOpt;
var elSel = document.getElementById(list);
try {
elSel.add(y, null); // standards compliant; doesn't work in IE
}
catch(ex) {
elSel.add(y); // IE only
}
}
我认为问题出在实际按钮中:
<img src="${resource(dir:'images',file:'arrow.png')}" onclick="addToList('BList','first','second')"/>
当我单击它时,“第一 - 第二”被添加到列表中,而不是 g:select 框的实际值。我还尝试了 ${first}
和 ${second}
但没有运气。
非常感谢任何帮助,谢谢!
I have two g:select comboboxes that I want to add to the multiple select list when clicking an image.
Here is the function in javascript:
function addToList(list,firstOpt, secOpt)
{
var y = document.createElement('option');
y.text = firstOpt + ' - ' + secOpt;
y.value = firstOpt+'-'+secOpt;
var elSel = document.getElementById(list);
try {
elSel.add(y, null); // standards compliant; doesn't work in IE
}
catch(ex) {
elSel.add(y); // IE only
}
}
I think the problem is here in the actual button:
<img src="${resource(dir:'images',file:'arrow.png')}" onclick="addToList('BList','first','second')"/>
when I click it, "first - second" gets added to the list, not the actual value of the g:select boxes. I also tried ${first}
and ${second}
but had no luck.
Any help is greatly appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那里没有任何代码来检索第一个和第二个选择列表的值。
您可能需要这样的东西:
然后您可以将其与以下选择一起使用:
You don't have any code in there that retrieves the values of the first and second select lists.
You would probably need something like this:
You might then use this with the following selects: