Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2002
    Messaggi
    585

    select dinamiche concatenate e array

    Ciao a Tutti,

    mi spiace dover proporre un nuovo problema inerente la relazione tra un valore di menu' selezionato e un valore di un array di un' altra select...

    Nel PRIMO menu' seleziono una email,
    in base all' email selezionata nel SECONDO menu' si apre un lista di problemi ed un campo Free Text...

    Vorrei che, SOLO SE uno seleziona email1 OPPURE email2,
    qualora la scelta cada su "Free Text",
    nel terzo menu' si attivi automaticamente il menu' "Scegli la Priorita ..." con le 2 opzioni da scegliere Urgent, Normal

    Per ora tutto funziona bene solo se scelgo email1,
    con email2 non succede niente ....


    <head>
    //
    var summary_db = new Object()
    var prior_db = new Object()
    summary_db["email1"] = [{value:"Problemi di primo livello, text:"Problemi di primo livello"},
    {value:"Problemi di schedule", text:"Problemi di schedule"},
    {value:"Free Text", text:"Free Text"}];
    summary_db["email2"] = [{value:"Free Text", text:"Free Text"}];
    prior_db["Problemi di primo livello"] = [{value:"2 hours", text:"2 hours"}];
    prior_db["Problemi di schedule"] = [{value:"4 hours", text:"4 hours"}];
    prior_db["Free Text"] = [{value:"Normal (5 days)", text:"Normal (5 days)"},{value:"Urgent (1 day)", text:"Urgent (1 day)"}];
    //
    function setIssue(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var Iss_Chooser = chooser.form.elements["iss_sum"];
    while (Iss_Chooser.options.length) {
    Iss_Chooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = summary_db[choice];
    if (choice == "email1") {
    newElem = document.createElement("option");
    newElem.text = "Choose an Issue ...";
    newElem.value = "Choose Issue ...";
    Iss_Chooser.add(newElem, where);
    }
    for (var i = 0; i < db.length; i++) {
    newElem = document.createElement("option");
    newElem.text = db[i].text;
    newElem.value = db[i].value;
    Iss_Chooser.add(newElem, where);
    }
    }
    //
    function setPriority(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var prChooser = chooser.form.elements["priority"];
    while (prChooser.options.length) {
    prChooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = prior_db[choice];
    if (choice=="Free Text") {
    newElem = document.createElement("option");
    newElem.text = "Scegli la Priorita ...";
    newElem.value = "Scegli la Priorita ...";
    prChooser.add(newElem, where);
    }
    for (var i = 0; i < db.length; i++) {
    newElem = document.createElement("option");
    newElem.text = db[i].text;
    newElem.value = db[i].value;
    prChooser.add(newElem, where);
    }
    }
    //
    </script>
    </head>

    <body>
    <form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form1">

    <select name="mess" id="mess" onchange="setIssue(this)">
    <option value="<%=objRS("Mess")%>" selected><%=objRS("Mess")%></option>
    <option value="email1">Mail 1</option>
    <option value="email2">Mail 2</option>
    </select>


    <select id="iss_sum" name="iss_sum" onchange="setPriority(this)">
    <option value="<%=objRS("Summary")%>" selected><%=objRS("Summary")%></option>
    </select>


    <select name="priority" id="priority">
    <option value="<%=objRS("Priority")%>" selected><%=objRS("Priority")%></option>
    </select>

    </body>


    Di questo codice capisco i limiti ...
    Vorrei che se uno seleziona email2 nel primo menu',
    automaticamente nel terzo menu' compare la scritta "Scegli la Priorita ..." con sotto le 2 opzioni da scegliere ...

    Grazie infinite in anticipo !!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2002
    Messaggi
    585
    Sto pensando ad una sintassi che mi dica:

    se uno seleziona email2,
    allora nel terzo menu' devono comparire automaticamente i 2 valori contenuti nel prior_db["Free Text"] = [{value:"Normal (5 days)", text:"Normal (5 days)"},{value:"Urgent (1 day)", text:"Urgent (1 day)"}];


  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2002
    Messaggi
    585
    Ho risolto !!!

    Ho aggiunto in rosso le parti mancanti ...

    <head>
    //
    var summary_db = new Object()
    var prior_db = new Object()
    summary_db["email1"] = [{value:"Problemi di primo livello, text:"Problemi di primo livello"},
    {value:"Problemi di schedule", text:"Problemi di schedule"},
    {value:"Free Text", text:"Free Text"}];
    summary_db["email2"] = [{value:"Free Text", text:"Free Text"}];
    prior_db["Problemi di primo livello"] = [{value:"2 hours", text:"2 hours"}];
    prior_db["Problemi di schedule"] = [{value:"4 hours", text:"4 hours"}];
    prior_db["Free Text"] = [{value:"Normal (5 days)", text:"Normal (5 days)"},{value:"Urgent (1 day)", text:"Urgent (1 day)"}];
    //
    function setIssue(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var Iss_Chooser = chooser.form.elements["iss_sum"];
    while (Iss_Chooser.options.length) {
    Iss_Chooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = summary_db[choice];
    if (choice == "email1") {
    newElem = document.createElement("option");
    newElem.text = "Choose an Issue ...";
    newElem.value = "Choose Issue ...";
    Iss_Chooser.add(newElem, where);
    }
    for (var i = 0; i < db.length; i++) {
    newElem = document.createElement("option");
    newElem.text = db[i].text;
    newElem.value = db[i].value;
    Iss_Chooser.add(newElem, where);
    }
    }
    //
    function setPriority(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var prChooser = chooser.form.elements["priority"];
    while (prChooser.options.length) {
    prChooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = prior_db[choice];
    if (choice=="Free Text") {
    newElem = document.createElement("option");
    newElem.text = "Scegli la Priorita ...";
    newElem.value = "Scegli la Priorita ...";
    prChooser.add(newElem, where);
    }
    for (var i = 0; i < db.length; i++) {
    newElem = document.createElement("option");
    newElem.text = db[i].text;
    newElem.value = db[i].value;
    prChooser.add(newElem, where);
    }
    }
    //
    function setJump(chooser) {
    var choice = chooser.options[chooser.selectedIndex].value;
    if (choice=="mail2") {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var jpChooser = chooser.form.elements["priority"];
    while (jpChooser.options.length) {
    jpChooser.remove(0);
    }
    newElem = document.createElement("option");
    newElem.text = "Scegli la priorita ...";
    newElem.value = "Scegli la priorita ...";
    jpChooser.add(newElem, where);
    newElem = document.createElement("option");
    newElem.text = "Normal (5 days)";
    newElem.value = "Normal (5 days)";
    jpChooser.add(newElem, where);
    newElem = document.createElement("option");
    newElem.text = "Urgent (1 day)";
    newElem.value = "Urgent (1 day)";
    jpChooser.add(newElem, where);
    }
    }

    //
    </script>
    </head>

    <body>
    <form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form1">

    <select name="mess" id="mess" onchange="setIssue(this);setJump(this) ">
    <option value="<%=objRS("Mess")%>" selected><%=objRS("Mess")%></option>
    <option value="email1">Mail 1</option>
    <option value="email2">Mail 2</option>
    </select>


    <select id="iss_sum" name="iss_sum" onchange="setPriority(this)">
    <option value="<%=objRS("Summary")%>" selected><%=objRS("Summary")%></option>
    </select>


    <select name="priority" id="priority">
    <option value="<%=objRS("Priority")%>" selected><%=objRS("Priority")%></option>
    </select>

    </body>

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.