【发布时间】:2013-10-04 04:29:18
【问题描述】:
我的 _form.gsp 上有一个动态下拉列表,它在创建和编辑 gsp 中都呈现。它工作正常,但我希望将所选值显示在 edit.gsp 上。
_form.gsp
<g:select name="plant.id" id="plant" from="${MCM.MGPlant.list(sort:'member')}" value="${MGMatriceInstance?.plant?.id}" optionKey="id" noSelection="${[null: 'Select One...']}"
onchange='loadCostCenter(this.value);'/>
<g:select id="costCenter" name="costCenter.id" from="${[]}" optionKey="id" noSelection="${[null: 'Select One...']}"/>
<script type="text/javascript">
function loadCostCenter(init)
{
var root="${resource()}";
var plantid = document.getElementById('plant').value;
var url = root+'/MGMatrices/findCostCenterForPlant?plantId='+plantid;
jQuery('#costCenter').load(url);
}
</script>
【问题讨论】:
-
尝试在植物选择中,使用值属性
-
我添加了它并且它有效。我还希望第二个下拉列表也显示所选值。但它在那里不起作用。
-
在我的答案字段中查看更新后的代码
标签: javascript ajax grails drop-down-menu