Search code examples
grailsgspgrails-domain-class

How to show or hide fields on a GSP based on a selection in a combo-box


I'm still new to grails, so I'm really sorry for asking something like this.

I have a domain that could be divided in 3 types, so I'd like to create a combo-box and depending on which selection the user made, it will show some fields and hide others. How can I achieve this?

Thanks again and sorry for this dumb question.


Solution

  • This is actually something that is commonly done with JavaScript. You could attach an 'on change' event handler to your combo-box that would show/hide the appropriate elements as needed. In case you're not familiar with how to do this with Javascript, I'd recommend you take a look at jQuery: http://api.jquery.com/change/