Let's say we have a domain class Country
with the next relationship:
Town town
And a domain class Town with:
Integer id
String town
The select works well fine with the following line of code (I'm using Grails Fields plugin):
<f:field bean="countryInstance" property="town" input-optionValue="town"/>
I want to get the optionValue, but the next code examples get the id:
var townName= document.getElementById("town").value;
var townName= document.getElementById("town").options[document.getElementById("town").selectedIndex].value;
The next code didn't work (this is the attempt to navigate through classes with Javascript):
var townName= document.getElementById("town").town.value;
How could I get the optionValue (or navigate through the relationship) to get String town
instead Integer id
?