Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    select

    codice:
    <script type="text/javascript">
    var autistadb = new Object()
    autistadb["14"] = [{value:"2", text:"Fiat 500 - BB 111 BB"},
    {value:"1", text:"Fiat Punto - AA 000 AA"},
    {value:"4", text:"Panda - AV123GR"}];
    autistadb["8"] = [{value:"4", text:"Panda - AV123GR"},
    {value:"2", text:"Fiat 500 - BB 111 BB"},
    {value:"1", text:"Fiat Punto - AA 000 AA"}];
    autistadb["10"] = [];
    autistadb["9"] = [];
    autistadb["16"] = [{value:"4", text:"Panda - AV123GR"}];
    
    function setAut(chooser) {
        var newElem;
        var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
        var autChooser = chooser.form.elements["Auto"];
        while (autChooser.options.length) {
            autChooser.remove(0);
        }
        var choice = chooser.options[chooser.selectedIndex].value;
        var db = autistadb[choice];
        newElem = document.createElement("option");
        newElem.text = "Seleziona l'auto:";
        newElem.value = "";
        autChooser.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;
                autChooser.add(newElem, where);
            }
        }
    }
    
    </script>
    Con questo script in base al valore Autista mi da i collegamenti Auto, se in {value:"2", text:"Fiat 500 - BB 111 BB"} voglio mettere un selected come faccio?

  2. #2

    Re: select

    codice:
    <script type="text/javascript">
    var autistadb = new Object()
    autistadb["14"] = [{value:"2", text:"Fiat 500 - BB 111 BB"},
    {value:"1", text:"Fiat Punto - AA 000 AA"},
    {value:"4", text:"Panda - AV123GR"}];
    autistadb["8"] = [{value:"4", text:"Panda - AV123GR"},
    {value:"2", text:"Fiat 500 - BB 111 BB"},
    {value:"1", text:"Fiat Punto - AA 000 AA"}];
    autistadb["10"] = [];
    autistadb["9"] = [];
    autistadb["16"] = [{value:"4", text:"Panda - AV123GR"}];
    
    function setAut(chooser) {
        var newElem;
        var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
        var autChooser = chooser.form.elements["Auto"];
        while (autChooser.options.length) {
            autChooser.remove(0);
        }
        var choice = chooser.options[chooser.selectedIndex].value;
        var db = autistadb[choice];
        newElem = document.createElement("option");
        newElem.text = "Seleziona l'auto:";
        newElem.value = "";
        autChooser.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;
                if(db[i].value=='2'){
                     newElem.selected="selected";
                } 
                autChooser.add(newElem, where);
            }
        }
    }
    
    </script>

  3. #3

  4. #4
    Ergo, funziona ma devo riselezionare l'autista, l'elenco dovrebbe uscire all'apertura della pagina

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.