Hello, i just have the same problem with Struts. Thanks of this post, i have found one solution but now i have a new problem.
I have a Form with one <html:select> and severals fields <html:radio> associated. When i click in one radio field, the list of values change in a select field (others values).
Contenido : <html:select property="contenido" size="1"></html:select>
<html:radio property="tipocontenido" value="conindata" onclic="changeContenidosEjercicio(this.value);"/>Conducta
<html:radio property="tipocontenido" value="gesindata" onclic="changeContenidosEjercicio(this.value);"/>Gesto
I can realize this operation fine with this javascript function (Previosly i have loaded in various arrays (Arrayconindata,Arraygesindata) the diferent values:
------------------------------------------------------
function changeContenidosEjercicio(control){
contenidosArray = new Array();
contenidosEjercicio = document.forms['ejercicioForm'].contenido;
contenidosEjercicio.options.length=0;
if (control == 'conindata') {contenidosArray = Arrayconindata;}
if (control == 'gesindata') {contenidosArray = Arraygesindata;}
for (i=0; i < contenidosArray.length;i++)
contenidosEjercicio.options[i] = contenidosArray[i];
}
-------------------------------------------------------------
Now, i have to recover several beans and show it in a
jsp with their values stored. For realize this, i have used indexed="true" in a fields and the javascript function have been modified a litle (adding a index):
<logic:iterate id="controles" name="listaejercicios" indexId="contador">
Contenido : <html:select name="controles" property="contenido" indexed="true" size="1"></html:select>
<html:radio name="controles" property="tipocontenido" value="conindata" indexed="true" onclic="changeContenidosControl(this.value,this.name);"/>Conducta
<html:radio name="controles" property="tipocontenido" value="gesindata" indexed="true" onclic="changeContenidosControl(this.value,this.name);"/>Gesto I
.....
----------------------------------
function changeContenidosControl(control,name){
var contenidosArray = new Array();
var ind = name.substring( name.indexOf('[') +1 ,name.lastIndexOf(']') );
var id = parseInt(ind,10);
var contenidosControl = document.forms['controldinamicoForm'].elements["controles["+ id +"].contenido"];
contenidosControl.options.length = 0;
if (control == 'conindata') {contenidosArray = Arrayconindata;}
if (control == 'gesindata') {contenidosArray = Arraygesindata;}
for (i=0; i < contenidosArray.length;i++)
contenidosControl.options[i] = contenidosArray[i]; }
If i show various records (beans) in a jsp, if i only ckecked one radio button works fine, but if i ckecked the same radio button of other record (bean) throws an error: "the object don�t accept this property or method"
Sorry for my english. Any idea?