sono riuscito ad ottenere l'array composto da tutti e 4 i checkbox.
questo il codice:
codice HTML:
var allChecks = document.testform.elements[c.name];var tot = 0;for (var i = 0; i < allChecks.length; i++) {miastringa = new String(allChecks[i].value)miaarray = miastringa.split("|")document.write(miaarray[1]+"<br>");//document.write(miaarray+"<br>");
//tot += (allChecks[i].checked ? parseFloat(prova[i].value) : 0);}
Il risultato che ottengo con il document.write è il seguente :
codice:
21,00
5,00
10,00
8,00
Ora però devo far in modo che se è il primo valore il cliccato (21,00) sia aggiunto alla funzione di somma, se clicco anche il terzo aggiunge etc. Il codice completo :
codice HTML:
<script language="javascript">function calcolaTotale(c) {var one=0;one = <?php echo($xml->Importo);?> ;var allChecks = document.testform.elements[c.name];var tot = 0;for (var i = 0; i < allChecks.length; i++) {miastringa = new String(allChecks[i].value)miaarray = miastringa.split("|")document.write(miaarray[1]+"<br>");//document.write(miaarray+"<br>");//tot += (allChecks[i].checked ? parseFloat(allChecks[i].value) : 0);}document.testform.totale.value = tot;document.testform.myresult.value = ((one * 1) + (tot * 1));}</script>
non riesco...