Cita:
Imagen del problema: var _rud = [
["RUD", "Rudimentario Provisional"],
["INE", "Industrial naves Económico"],
["INEM", "Industrial naves Económico mediano"],
["INM", "Industrial naves Mediano"],
["INMC", "Industrial naves Mediano calidad"],
["INC", "Industrial naves Calidad"],
["INCL", "Industrial naves Calidad lujo"],
["INC", "Industrial naves Calidad"],
["INCL", "Industrial naves Calidad"],
["INL", "Industrial naves Lujo"],
["AT", "Antigüo Típico"],
["ATC", "Antigüo Típico común"],
["AC", "Antigüo común"],
["ACN", "Antigüo Común notable"],
["AN", "Antigüo Notable"],
["ANR", "Antigüo Notable relevante"],
["AR", "Relevante"],
["ME", "Moderno Económico"],
["MEM", "Moderno Económico mediano"],
["MM", "Moderno Mediano"],
["MMC", "Moderno Mediano calidad"],
["MC", "Moderno Calidad"],
["MCL", "Moderno Calidad lujo"],
["ML", "Moderno Lujo"]// Entire array not shown
];
$("#addColin").click(function (){
$('#colindancias').before(
"<tr><td height='18' valign='top' class='campos'><div align='center'><input type='text' name='t1' size='2' maxlength='2' id='t1' value='' class='general'></div></td><td colspan='4' valign='top' class='campos'><select name='desc1' id='desc1' class='general'><option value="+_rud[1][0]+"> "+_rud[1][1]+" </option></select></td><td valign='top' class='campos'><input type='text' name='niveles1' size='2' maxlength='2' id='niveles1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='edad1' size='2' maxlength='2' id='edad1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='vur1' size='5' maxlength='5' id='vur1' value='' class='general'></td><td valign='top' class='campos'><select name='conserv1' id='conserv1' class='general'><option value='' > </option></select></td></tr>" );
["RUD", "Rudimentario Provisional"],
["INE", "Industrial naves Económico"],
["INEM", "Industrial naves Económico mediano"],
["INM", "Industrial naves Mediano"],
["INMC", "Industrial naves Mediano calidad"],
["INC", "Industrial naves Calidad"],
["INCL", "Industrial naves Calidad lujo"],
["INC", "Industrial naves Calidad"],
["INCL", "Industrial naves Calidad"],
["INL", "Industrial naves Lujo"],
["AT", "Antigüo Típico"],
["ATC", "Antigüo Típico común"],
["AC", "Antigüo común"],
["ACN", "Antigüo Común notable"],
["AN", "Antigüo Notable"],
["ANR", "Antigüo Notable relevante"],
["AR", "Relevante"],
["ME", "Moderno Económico"],
["MEM", "Moderno Económico mediano"],
["MM", "Moderno Mediano"],
["MMC", "Moderno Mediano calidad"],
["MC", "Moderno Calidad"],
["MCL", "Moderno Calidad lujo"],
["ML", "Moderno Lujo"]// Entire array not shown
];
$("#addColin").click(function (){
$('#colindancias').before(
"<tr><td height='18' valign='top' class='campos'><div align='center'><input type='text' name='t1' size='2' maxlength='2' id='t1' value='' class='general'></div></td><td colspan='4' valign='top' class='campos'><select name='desc1' id='desc1' class='general'><option value="+_rud[1][0]+"> "+_rud[1][1]+" </option></select></td><td valign='top' class='campos'><input type='text' name='niveles1' size='2' maxlength='2' id='niveles1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='edad1' size='2' maxlength='2' id='edad1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='vur1' size='5' maxlength='5' id='vur1' value='' class='general'></td><td valign='top' class='campos'><select name='conserv1' id='conserv1' class='general'><option value='' > </option></select></td></tr>" );
(aquí se muestra, cómo se agrega únicamente el primer valor del arreglo y no todos cómo quisiera)
¿La pregunta es ¿cómo hago para insertar TODOS los valores del arreglo en el option que inserto?
Así lo obtengo:
//for (var i=1; i<=_rud.length;i++) alert(i);
Pero si hago esto me repite toda la columna y lo unico q quiero q repita son los option box:
Cita:
for (var i=1; i<=_rud.length;i++){
$('#colindancias').before(
"<tr><td height='18' valign='top' class='campos'><div align='center'><input type='text' name='t1' size='2' maxlength='2' id='t1' value='' class='general'></div></td><td colspan='4' valign='top' class='campos'><select name='desc1' id='desc1' class='general'><option value="+_rud[i][0]+"> "+_rud[i][1]+" </option></select></td><td valign='top' class='campos'><input type='text' name='niveles1' size='2' maxlength='2' id='niveles1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='edad1' size='2' maxlength='2' id='edad1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='vur1' size='5' maxlength='5' id='vur1' value='' class='general'></td><td valign='top' class='campos'><select name='conserv1' id='conserv1' class='general'><option value='' > </option></select></td></tr>" );
}
$('#colindancias').before(
"<tr><td height='18' valign='top' class='campos'><div align='center'><input type='text' name='t1' size='2' maxlength='2' id='t1' value='' class='general'></div></td><td colspan='4' valign='top' class='campos'><select name='desc1' id='desc1' class='general'><option value="+_rud[i][0]+"> "+_rud[i][1]+" </option></select></td><td valign='top' class='campos'><input type='text' name='niveles1' size='2' maxlength='2' id='niveles1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='edad1' size='2' maxlength='2' id='edad1' value='' class='general'></td><td valign='top' class='campos'><input type='text' name='vur1' size='5' maxlength='5' id='vur1' value='' class='general'></td><td valign='top' class='campos'><select name='conserv1' id='conserv1' class='general'><option value='' > </option></select></td></tr>" );
}