检索g:从gsp中选择值 - 无表单 [英] Retrieving g:select value from within gsp - No form

查看:79
本文介绍了检索g:从gsp中选择值 - 无表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在链接操作中传递g:select框的值:

 < g:select name =sel.nfrom =$ {personList}value =/> 

如何检索选择框sel.n的值以传入该操作链接?



这不是表单。

解决方案

使用jQuery来做这样的事情。下面是一个应该让你开始走正确道路的例子。

  var val =; 
$('#sel \\.n')。change(function(){

val = $(this).text();

$(a)。attr('href',function(i,h){
return h +(h.indexOf('?')!= -1?&:? )+selectValue =+ val;

});
});

当选择框发生变化,然后改变href链接的查询字符串时,上面的代码就会被捕获。如果你不熟悉jQuery,你需要通过一些基础知识来运行它,这是一个这样的事情的重要工具。祝你好运,享受!

How does one pass the value of the g:select box in a link action:

<g:select name="sel.n" from="${personList}" value="" />
<g:link action="addValue" params="${[personID: personInstance.id, selectionVal: sel.n.value]}">Add</g:link>

How do I retrieve the value of the selection box sel.n to pass in that action link?

This is NOT a form.

解决方案

You'll want to use jQuery for something like this. Below is a sample that should get you started down the right path.

var val = "";
$('#sel\\.n').change(function() {

    val = $(this).text();

    $("a").attr('href', function(i, h) {
            return h + (h.indexOf('?') != -1 ? "&" : "?") + "selectValue="+val;

    });
});

The above code will catch when the select box changes and then alters the query string of the href link. If your unfamiliar with jQuery you'll need to run through some basics it's an essential tool for things like this. Good luck and enjoy!

这篇关于检索g:从gsp中选择值 - 无表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆