Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/06/2011, 10:11
Avatar de dudu_10
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>