Listas dependientes
Es una lista de valores, al pinchar en uno se abre otro desplegable con otra lista de valores. El primer desplegable est谩 ordenado alfab茅ticamente, pero yo quiero que por defecto me salga el que tengo en 6º lugar, c贸mo lo hago? Tengo el siguiente c贸digo:
for (var i=0; i < valores.length; i++)
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'">'+
valores[i]+'</OPTION>');
for (var i=0; i < valores.length; i++)
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'">'+
valores[i]+'</OPTION>');
Puedes probar con esto:
for (var i=0; i < valores.length; i++)
if (i==5){ // sexto lugar del array
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'" selected>'+
valores[i]+'</OPTION>');
}
else {
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'" >'+
valores[i]+'</OPTION>');
}
O casi mejor esto:
window.document.writeln('<form name="form1"><select name="select1">');
for (var i=0; i < valores.length; i++){
window.document.writeln('<OPTION VALUE="'+valores[i]+'">'+
valores[i]+'</OPTION>');
}
window.document.writeln('</select></form>');
document.form1.select1.value=document.form1.select1.options[5].text;
No se si es lo que buscas.
rsalvadores
for (var i=0; i < valores.length; i++)
if (i==5){ // sexto lugar del array
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'" selected>'+
valores[i]+'</OPTION>');
}
else {
window.document.writeln('<OPTION VALUE="'+codvalor[i]+'" >'+
valores[i]+'</OPTION>');
}
O casi mejor esto:
window.document.writeln('<form name="form1"><select name="select1">');
for (var i=0; i < valores.length; i++){
window.document.writeln('<OPTION VALUE="'+valores[i]+'">'+
valores[i]+'</OPTION>');
}
window.document.writeln('</select></form>');
document.form1.select1.value=document.form1.select1.options[5].text;
No se si es lo que buscas.
rsalvadores
