Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/05/2010, 10:24
m0m0o
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/México
Mensajes: 57
Antigüedad: 15 años
Puntos: 0
Respuesta: seleccionar el ultimo agregado en un select

jeje justo iba a postear esa duda despues de hacer esto

Código:
function agrega(){
	var lista=document.form1.uno;
	var indice;
	var opcion = document.createElement("option");
	var contenido = document.createTextNode("dos");
	opcion.appendChild(contenido);
	lista.appendChild(opcion);
	indice=optionUltimo();		
	alert("probando que se tiene el indice "+indice);
	//lista.options[indice].value.selected
	//lista.options[indice].selected	
	//lista.selectedIndex[indice]	
	//document.body.select.selectedIndex[indice].selected;
	//document.body.select.selectedIndex[indice]
	//lista.selected[indice]
	//lista[indice].selected
	
}
function optionUltimo(){
	var lista=document.form1.uno;
	ultimo=(lista.length-1);	
	return ultimo;
}
y agregando el

Código:
document.form1.uno.selectedIndex=indice;
ya me funciona correctamente, muchas gracias a los dos


saludos