Foros del Web » Creando para Internet » Diseño web »

Mantener seleccion combobox, javascript o algo pero no php

Estas en el tema de Mantener seleccion combobox, javascript o algo pero no php en el foro de Diseño web en Foros del Web. Hola, tengo un problema, tengo 2 combobox con 5 seleciones cada uno, cuando selecciono alguna y le doy el boton que ejecuta la accion, me ...
  #1 (permalink)  
Antiguo 25/11/2010, 11:07
 
Fecha de Ingreso: octubre-2010
Mensajes: 136
Antigüedad: 13 años, 5 meses
Puntos: 4
Pregunta Mantener seleccion combobox, javascript o algo pero no php

Hola, tengo un problema, tengo 2 combobox con 5 seleciones cada uno, cuando selecciono alguna y le doy el boton que ejecuta la accion, me devuelve a los que vienen como predeterminados con "selected" aunque les quite eso a todos siempre me dejan uno predeterminado automáticamente, quiero que después de la acción se mantega la selección con que realice la misma...aqui les dejo el codigo...Por favor y gracias...
<label for="combo1"></label>
<select name="combo1" id="combo1">
<option value="1=">1</option>
<option value="2=">2</option>
<option value="3=">3</option>
<option value="4=">4</option>
<option value="5=">5</option>
</select>
&amp;
<label for="combo2"></label>
<select name="combo2" id="combo2">
<option value="6=">6</option>
<option value="7=" selected="selected">7</option>
<option value="8=">8</option>
<option value="9=">9</option>
<option value="10=">10</option>
</select>
  #2 (permalink)  
Antiguo 02/06/2011, 10:11
Avatar de dudu_10  
Fecha de Ingreso: febrero-2008
Mensajes: 36
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Mantener seleccion combobox, javascript o algo pero no php

Yo tengo este codigo y no funciona en firefox

<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
// primer combo box

data_1 = new Option("Primero", "$");

// second combo box

data_1_1 = new Option("Segundo", "-");

// third combo box

data_1_1_1 = new Option("Tercero", "-");

// fourth combo box

data_1_1_1_1 = new Option("Singular", "URL");

displaywhenempty="...."
valuewhenempty=-1

displaywhennotempty="Seleccionar..."
valuewhennotempty=0


function change(currentbox) {
numb = currentbox.id.split("_");
currentbox = numb[1];

i=parseInt(currentbox)+1

while ((eval("typeof(document.getElementById(\"combo_"+i +"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
son = document.getElementById("combo_"+i);
// Vacio todas las opciones excepto la primera ( No esta permitido )
for (m=son.options.length-1;m>0;m--) son.options[m]=null;
// Reseteo la primera opcion
son.options[0]=new Option(displaywhenempty,valuewhenempty)
i=i+1
}



stringa='data'
i=0
while ((eval("typeof(document.getElementById(\"combo_"+i +"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
eval("stringa=stringa+'_'+document.getElementById( \"combo_"+i+"\").selectedIndex")

if (i==currentbox) break;

i=i+1

}

following=parseInt(currentbox)+1

if ((eval("typeof(document.getElementById(\"combo_"+f ollowing+"\"))!='undefined'")) &&
(document.getElementById("combo_"+following)!=null )) {
son = document.getElementById("combo_"+following);
stringa=stringa+"_"
i=0

while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

// Si no hay opciones, vacio la primera opcion del combo " Hijo " ( son )
// De lo contrario, pongo el mensaje "- seleccionar -"

if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")

else
eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")

else
eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
son.options.disabled=false
i=i+1

}
//son.focus()
i=1
combostatus=''
cstatus=stringa.split("_")
while (cstatus[i]!=null) {


combostatus=combostatus+cstatus[i]
i=i+1

}
return combostatus;

}

}

// -->
</script>

</head>

<table align="left">
<form name="f1" method="post" action="verificar.php">

<select name="combo0" id="combo_0" onChange="change(this);" style="width:120px;">
<option value="value1">Selecciona...</option>
<option value="value2">Primero</option>
</select>
<br />
<select name="combo1" id="combo_1" onChange="change(this)" style="width:120px;" disabled>
<option value="value1"> </option>
</select>
<br />
<select name="combo2" id="combo_2" onChange="change(this);" style="width:120px;" disabled>
<option value="value1"> </option>
</select>
<br />
<select name="combo3" id="combo_3" onChange="change(this);" style="width:120px;" disabled>
<option value="value1"> </option>
</select>
<INPUT TYPE=button VALUE="ok"
onClick="top.location.href=this.form.combo3.option s[this.form.combo3.selectedIndex].value">
</select>
</form>
</table>
</body>
</html>

Etiquetas: combobox, javascript, mantener, php, seleccion
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 04:14.