Ho un problema. Sto cercando di validare con le norme xhtml 1.0 strict questo stupidissimo esercizio:
Codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it"> <head> <title>Posto barca</title> <link type="text/css" rel="Stylesheet" href="(z)esj01.css"/> <script type="text/JavaScript"> function ottieni_prezzo() { var lung = document.forms[0].lunghezza.value; var larg = document.forms[0].larghezza.value; var sup = lung * larg; if ((document.forms[0].elements[2].checked) && (document.forms[0].elements[5].checked)) { document.forms[0].elements[9].value = sup * 10; } else if ((document.forms[0].elements[3].checked) && (document.forms[0].elements[5].checked)) { document.forms[0].elements[9].value = sup * 10 * 0.7; } else if (((document.forms[0].elements[4].checked) && (document.forms[0].elements[5].checked)) || ((document.forms[0].elements[2].checked) && (document.forms[0].elements[6].checked))) { document.forms[0].elements[9].value = sup * 10 * 0.5; } else if ((document.forms[0].elements[3].checked) && (document.forms[0].elements[6].checked)) { document.forms[0].elements[9].value = sup * 10 * 0.7 * 0.5; } else if ((document.forms[0].elements[4].checked) && (document.forms[0].elements[6].checked)) { document.forms[0].elements[9].value = sup * 10 * 0.5 * 0.5; } } </script> </head> <body> <h2>Calcolo del prezzo giornaliero</h2> <form action="#" method="post"> <div id="lg"><p>Lunghezza:</p><input type="text" name="lunghezza" size="10"/></div> <div id="wd"><p>Larghezza:</p><input type="text" name="larghezza" size="10"/></div> <div id="use"><p>Utilizzo:</p> <input type="radio" name="utilizzo" checked="checked"/>diporto <input type="radio" name="utilizzo"/>uso professionale <input type="radio" name="utilizzo"/>ONLUS</div> <div id="type"><p>Tipologia di posto:</p> <input type="radio" name="tipo_posto" checked="checked"/>posto in acqua <input type="radio" name="tipo_posto"/>posto a terra</div> <div id="bottoni"><input type="reset" value="inizializza form"/> <input type="button" value="prezzo" onclick="ottieni_prezzo();"/></div> <div id="res"><p>Prezzo: </p><input type="text" name="prezzo"/>euro al giorno</div> </form> </body> </html>
Il problema č che mi dā errore sugli ampersand utilizzati per l'and di javascript
Non so come risolvere il problema, vorrei evitare di mettere lo script su un file esterno.
Segnalibri