Salve ragazzi ho trovato una select carica che in base alla option selezionata mi cambia il div associato,questo pero fa un riferimento me index io vorrei mettere il valore alla option e richiamare il div in vase a quel valore ,come posso fare?
Qui vi riporto il codice
Codice PHP:
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<style type="text/css">
.areatesto{
width: 300px;
height: 180px;
border: 1px dashed black;
background-color: #f0f0f0;
display:block;
}
</style>
<script type="text/javascript">
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.areatesto{display:none;}\n')
document.write('</style>\n')
}
function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("messaggio"+inc)){
document.getElementById("messaggio"+inc).style.display="none"
inc++
}
}
}
function expandone(){
if (document.getElementById){
var selectedItem=document.messaggioform.messaggiooption.selectedIndex
contractall()
document.getElementById("messaggio"+selectedItem).style.display="block"
}
}
if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)
</script>
</head>
<body >
<div align="center">
<form name="messaggioform">
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td>
<select name="messaggiooption" size="1" style="width:300; background-color: #006699; color: white; font-family: Verdana, Tahoma; font-size: 10.75px;" onChange="expandone()">
<option selected>Cos'è HTML.it?</option>
<option>Chi c'è dietro HTML.it?</option>
<option>Quante persone lavorano ad HTML.it?</option>
</select>
</td>
</tr>
<tr align="center">
<td>
<div id="messaggio0">
<form method="post" action="#" class="button-to" >
<input type="text" />
<input type="submit" value="Add to Cart" />
</form>
</div>
<div id="messaggio1">
bene
</div>
<div id="messaggio2">
male
</div>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>