Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/01/2012, 17:36
jaimAcevedo
 
Fecha de Ingreso: noviembre-2011
Ubicación: Chile
Mensajes: 17
Antigüedad: 12 años, 5 meses
Puntos: 0
Como mantener un valor en un select con jquery

estimados, vuelvo a necesitar de su ayuda, estoy creando una fila con un select utilizando jquery, en una tabla, el problema q luego de crear una nueva fila el valor del select anterior vuelve a ser 0,el problema es como dejar el valor seleccionado en el select, antes de q se haya insertado una nueva fila, les dejo el codigo

Código:
var x=$(document);
x.ready(inicializarEventos);
function inicializarEventos()
{
	x=$('#agregarFila').click(agregarFila);
}
function agregarFila()
{
	var x=10;
	var y=0;
	var opciones;
	while(y!=x)
	{
		opciones=opciones+"<option value='"+y+"'>"+y+"</option>"
		y++;
	}
	$('#tabla').html($('#tabla').html()+"<tr><td><select id='StockVista-"+x+"' class='cambioNumerosLLevan'>"+opciones+"</select></td></tr>");
}
Y el HTML
Código HTML:
<table width="200" border="1" id="tabla">
<tr>
<td>select</td>
</tr>
  
</table>
<input name="agregarFila" id="agregarFila" value="agregar Fila" type="button" />