Ciao ragazzi,
grazie per le risposte! Ho adottato una via di mezzo tra le due soluzioni e ho superato lo scoglio. Grazie davvero!
Approfitto un attimo di voi e vi chiedo un altro aiutino se potete!
Come avete già capito, ho 'prestazione.html' nel quale voglio creare due select "a cascata": nella prima scelgo la prestazione, nella seconda il luogo di erogazione. Accanto alla seconda select mi piaceva inoltre farci apparire una mappa della zona dalla quale poter scegliere il luogo (con le mappe immagine) in alternativa all'uso della select.
Il problema oggi è con le mappe: su Chrome funzionano, HTMLKit, IE e Firefox no.... ho anche validato il codice! Come mai?
Poi un suggerimento: la funzione 'chirurgica' è troppo lunga? C'è il modo di scrivere meno codice e ottenere lo stesso risultato? Grazie!!
prenotazione.html
codice:
...
<form action="#" id="preno_form">
<p class="label">
<label class="block">1) scegli la prestazione che intendi prenotare:
<select onchange="gestioneSelezione(this.value)">
<option selected="selected" value="none"></option>
<option value="chirurgica">Visita chirurgica</option>
<option value="dermatologica">Visita dermatologica</option>
<option value="neurologica">Visita neurologica</option>
</select>
</label>
</p>
<hr style="visibility:hidden;">
</form>
...
prestazione.js
codice:
...
function gestioneSelezione(v)
{
//svuota();
document.getElementsByTagName("hr").item(0).style.visibility= "visible";
if (v=="chirurgica") chirurgica();
if (v=="dermatologica") dermatologica();
if (v=="neurologica") neurologica();
if (v=="none")
{
document.getElementsByTagName("hr").item(0).style.visibility= "hidden";
return;
}
}
...
chirurgica.js
codice:
function chirurgica()
{
var secondoPar= document.createElement("p");
secondoPar.setAttribute("class", "label");
var secondaLabel= document.createElement("label");
secondaLabel.setAttribute("class", "block");
var secondoPasso= document.createTextNode("2) scegli la sede della prestazione:\u00A0\u00A0");
var secondaSelect= document.createElement("select");
secondaSelect.setAttribute("name", "sede");
var primoOption= document.createElement("option");
primoOption.setAttribute("value", "none");
var secondoOption= document.createElement("option");
secondoOption.setAttribute("value", "castelfiorentino");
var terzoOption= document.createElement("option");
terzoOption.setAttribute("value", "empoli");
var primaSede= document.createTextNode("Castelfiorentino");
var secondaSede= document.createTextNode("Empoli");
secondoOption.appendChild(primaSede);
terzoOption.appendChild(secondaSede);
secondaSelect.appendChild(primoOption);
secondaSelect.appendChild(secondoOption);
secondaSelect.appendChild(terzoOption);
secondaLabel.appendChild(secondoPasso);
secondaLabel.appendChild(secondaSelect);
secondoPar.appendChild(secondaLabel);
secondoPar.style.float= "left";
var divmap= document.createElement("div");
var map= document.createElement("img");
map.setAttribute("src", "immagini/chirurgica.jpg");
map.setAttribute("alt", "mappa visita chirurgica");
map.setAttribute("usemap", "#chiru");
var mapchiru= document.createElement("map");
mapchiru.setAttribute("name", "chiru");
var area1= document.createElement("area");
area1.setAttribute("href", "../richieste_prestazioni/castelfiorentino_chiru.html");
area1.setAttribute("alt", "Castelfiorentino");
area1.setAttribute("shape", "circle");
area1.setAttribute("coords", "345,289,8");
var area2= document.createElement("area");
area2.setAttribute("href", "../richieste_prestazioni/empoli_chiru.html");
area2.setAttribute("alt", "Empoli");
area2.setAttribute("shape", "circle");
area2.setAttribute("coords", "315,75,8");
mapchiru.appendChild(area1);
mapchiru.appendChild(area2);
divmap.appendChild(map);
divmap.appendChild(mapchiru);
divmap.style.float= "right";
var formPreno= document.getElementById("preno_form");
formPreno.appendChild(secondoPar);
formPreno.appendChild(divmap);
}