Per collaudarlo rapidamente in locale, sostituisco $_POST['prezzo_cm'] con un ipotetico 2
Nota che la seconda tornata di if-statement nel determinare $somma2 trova $somma1 per come l' ultima esecuzione PHP la ha lasciata:
$somma1 = $_POST['prezzo_cm'] + 0; cioè uguale a $_POST['prezzo_cm']
Rendo visibile come textbox anche il campo hidden "theprice2"
dimmi cos'è che non ti torna:
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function priceit(its){ document.forms[0].elements["theprice"].value = its; } function priceit2(its){ document.forms[0].elements["theprice2"].value = its; } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento senza titolo</title> </head> <body> <form id="form1" name="form1" method="post" action=""> €. <input name="theprice" value="2" type="text" size="5"> </p> <input type="checkbox" name="iniziali" id="iniziali" onclick="if(this.checked){priceit(5 )}else{priceit(2)}" /> (<input name="theprice2" value="2" type="text" size="5" />) <label for="iniziali">Iniziali (+3€)</label> </p> <input type="checkbox" name="colletto" id="colletto" onclick="if(this.checked){priceit2(7)}else{priceit2(2)}" /> <label for="colletto">Colletto (+5€)</label> </p> </form> </body> </html>

Rispondi quotando