Ver Mensaje Individual
  #9 (permalink)  
Antiguo 11/02/2011, 16:32
CWeeD
 
Fecha de Ingreso: octubre-2010
Mensajes: 136
Antigüedad: 13 años, 6 meses
Puntos: 4
Exclamación Respuesta: Eliminar valores(option) iguales entre combobox

De hecho ya lo hacia de una forma anteriormente, con javascript, que me creaba los objetos del combo2 apartir de la opcion escogida en el combo1, funciona perfectamente, pero ahora estoy implementando cookies para mantener la ultima selección con que se trabajo, pero los cookies no me guardan el combo2 porque en realidad se crea a partir del primero...
Este es el código que use...
Código:
/***********************************************
* Create combo2
***********************************************/
var sedb = new Object()
sedb["http://www.gg.com/search?q="] = [{value:"http://search.yy.com/search?p=", text:"YY"},
                      {value:"http://search.aa.com/search?&q=", text:"AA"},
                      {value:"http://www.bb.com/search?q=", text:"BB"},
                      {value:"http://www.kk.com/web?q=", text:"KK"}];
sedb["http://search.yy.com/search?p="] = [{value:"http://www.gg.com/search?q=", text:"GG"},
                    {value:"http://search.aa.com/search?&q=", text:"AA"},
                    {value:"http://www.bb.com/search?q=", text:"BB"},
                    {value:"http://www.kk.com/web?q=", text:"KK"}];
sedb["http://search.aa.com/search?&q="] = [{value:"http://www.gg.com/search?q=", text:"GG"},
                    {value:"http://search.yy.com/search?p=", text:"YY"},
                    {value:"http://www.bb.com/search?q=", text:"BB"},
                    {value:"http://www.Kk.com/web?q=", text:"KK"}];
sedb["http://www.bb.com/search?q="] = [{value:"http://www.gg.com/search?q=", text:"GG"},
                    {value:"http://search.yy.com/search?p=", text:"YY"},
                    {value:"http://search.aa.com/search?&q=", text:"AA"},
                    {value:"http://www.kk.com/web?q=", text:"KK"}];
sedb["http://www.kk.com/web?q="] = [{value:"http://www.gg.com/search?q=", text:"GG"},
                    {value:"http://search.yy.com/search?p=", text:"YY"},
                    {value:"http://search.aa.com/search?&q=", text:"AA"},
                    {value:"http://www.bb.com/search?q=", text:"BB"}],

function setEngines(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var combo2Chooser = chooser.form.elements["combo2"];
    while (combo2Chooser.options.length) {
        combo2Chooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = sedb[choice];
    newElem = document.createElement("option");
    newElem.text = "Choose:";
    newElem.value = "";
    combo2Chooser.add(newElem, where);
    if (choice != "") {
        for (var i = 0; i < db.length; i++) {
            newElem = document.createElement("option");
            newElem.text = db[i].text;
            newElem.value = db[i].value;
            combo2Chooser.add(newElem, where);
        }
    }
}
Código:
<!--Combos -->
    <select name="combo1" onChange="combo2.selectedIndex=0;document.formulario.combo2.focus();" id="combo1">
    <option value="http://www.gg.com/search?q=" selected class="select">GG</option>
    <option value="http://search.yy.com/search?p=">YY</option>
    <option value="value:"http://search.aa.com/search?&q="">AA</option>
    <option value="http://www.bb.com/search?q=">BB</option>
    <option value="http://www.aa.com/web?q=">KK</option>
    </select>&nbsp;&amp;
<select name="combo2" id="combo2">
    <option value="" >Choose:</option>
</select>
Talvez le sirva a alguien por acá...
Pero ya me es inservible...lo que quisiera lograr es que si escojo la opcion1 en el combo1 la opcion1 del combo2 se ponga disabled o algo así...me entienden porque? evitar elegir ambas opciones iguales...ya que son comparativas...
__________________
Ser o conocer ese es el dilema...

Última edición por CWeeD; 11/02/2011 a las 16:42