Reputation: 41
I need to display a number of text box in a gsp. The number of text box displayed is picked in a select tag.
I think of something like
<g:select name="select" from="${1..10}>
<g:each in="${1..select}">
Is there any way I can "pass" the number selected in the select to use it in the for below?
Upvotes: 0
Views: 521
Reputation: 35961
GSP is working on server-side. Value of select tag is available only on client side.
So, the answer: No, you can't use <g:each
for selected value.
You have use Javascript instead, like:
<g:javascript>
function setupTextboxes() {
var count = Number($('select[name="select"]').val());
........
put your text boxes into DOM
........
}
$(function() {
$('select[name="select"]').on('change', setupTextboxes)
})
</g:javascript>
Upvotes: 2