0

Country次の関係を持つドメイン クラスがあるとします。

Town town

そして、ドメイン クラスの Town には次のものがあります。

Integer id
String town

選択は、次のコード行でうまく機能します (私は Grails フィールド プラグインを使用しています)。

<f:field bean="countryInstance" property="town" input-optionValue="town"/>

optionValue を取得したいのですが、次のコード例では ID を取得しています。

var townName= document.getElementById("town").value;
var townName= document.getElementById("town").options[document.getElementById("town").selectedIndex].value;

次のコードは機能しませんでした (これは、Javascript を使用してクラスをナビゲートしようとする試みです)。

var townName= document.getElementById("town").town.value;

String town代わりに optionValue を取得する (または関係をナビゲートする) にはどうすればよいInteger idですか?

4

1 に答える 1