下拉菜单的默认值

时间:2016-11-07 16:44:52

标签: javascript grails

您好如何设置此下拉菜单以使列表中的默认值为秒?这是dropmenu

<g:select name="dropmenu" from="${["First", "Second", "Third"]}"
           />

2 个答案:

答案 0 :(得分:0)

<g:select selected="Second" name="dropmenu" from="${["First", "Second", "Third"]}"
       />

信用:https://stackoverflow.com/users/1583/oded

Set Default Text in a Select (drop-down) box/menu

答案 1 :(得分:0)

您缺少value =属性。下面的示例还显示了值为null时的noSelection选项。

            <g:select id="initialOutcome" name="initialOutcome.id" optionKey="id" from="${OutcomeDescription.findAll())}"
                  value="${outcome?.initialOutcome?.id}" noSelection="['':'-Select-']" class="form-control" title="Initial Outcome" required=""/>