Qualcuno riesce a spiegarmi perché in questo codice mi vengono azzerati i decimali delle spese di spedizione? In questo modo il totale è diverso da quello effettuato.


  • DecimalFormat df = new DecimalFormat("#,###.00");
    double ss = 0.00;

    <script language="javascript">
    function checkOrdine(){
    ok = true;
    if (ok && document.getElementById("conto").checked == false && document.getElementById("contrassegno").checked == false && document.getElementById("carta").checked == false && document.getElementById("ritiro").checked == false) { alert("Impossibile ordinare senza scegliere il tipo di pagamento.");ok =false;}
    if (ok && document.getElementById("accetto").checked == false) { alert("Impossibile ordinare senza accettare le condizioni.");ok =false;}
    if (ok && document.getElementById("carta").checked == true)
    {
    if ( (Trim(document.getElementById("ccTitolare").value) == "") || (Trim(document.getElementById("ccNumero").value) == "")
    || (document.getElementById("ccAnno").selectedIndex == 0) || (document.getElementById("ccMese").selectedIndex == 0) ||
    (document.getElementById("ccVisa").checked == false && document.getElementById("ccMastercard").checked == false) )
    {
    alert('Impossibile procedere senza tutti i dati della carta di credito!');
    ok = false;
    }
    }
    if (ok) {
    document.getElementById("ordina").submit();
    }
    }

    function calcola() {
    var ss = 0.0;
    //
    if (document.getElementById("contrassegno").checked == true){
    if (document.getElementById("corriere").checked == true){
    ss = 19.00;
    }
    if (document.getElementById("poste").checked == true){
    ss = 7.50;
    }
    }
    if (document.getElementById("carta").checked == true || document.getElementById("conto").checked == true){
    if (document.getElementById("corriere").checked == true){
    ss = 30.50;
    }
    if (document.getElementById("poste").checked == true){
    ss = 8.00;
    }
    }
    if (document.getElementById("ritiro").checked == true){
    ss = 0.00;
    }
    document.getElementById("ss").value = ss;
    document.getElementById("ss1").value = ss;
    document.getElementById("totaless").value = ss + parseFloat(document.getElementById("totale").value );
    }

    function sblocca(){
    document.getElementById("corriere").disabled = false;
    document.getElementById("poste").disabled = true;
    calcola();
    if (document.getElementById("carta").checked == true)
    {
    document.getElementById("ccTable").style.visibilit y = "visible";
    document.getElementById("ccTable").style.display = "inline";
    }
    else
    {
    document.getElementById("ccTable").style.visibilit y = "hidden";
    document.getElementById("ccTable").style.display = "none";
    //
    document.getElementById("ccNumero").value='';
    document.getElementById("ccTitolare").value='';
    document.getElementById("ccMese").value='';
    document.getElementById("ccAnno").value='';
    }
    }

    function blocca(){
    document.getElementById("corriere").disabled = true;
    document.getElementById("poste").disabled = true;
    calcola();
    }

    </script>

    <form name="ordina" action="carrelloeng3.jsp" method="post" id="ordina">
    <tr>
    <td rowspan="3" align="left" valign="top">

    Method of payment for the REST OF THE WORLD:</p>


    <div align="center" class="invisibile" id="ccTable">
    <table width="380" border="0" cellpadding="5" cellspacing="0">
    <tr>
    <td class="normale"></td>
    <td class="normale"><div align="right">
    <div align="left">Credit Card details </div></td>
    </tr>
    <tr>
    <td width="74" class="normale"><div align="right">Owner</div></td>
    <td width="306"><input name="ccTitolare" type="text" id="ccTitolare" size="35"></td>
    </tr>
    <tr>
    <td class="normale"><div align="right">Card Number</div></td>
    <td><input name="ccNumero" type="text" id="ccNumero" size="35"></td>
    </tr>
    <tr>
    <td class="normale"><div align="right">Expiration date </div></td>
    <td>


    <select name = "ccMese" id ="ccMese">
    <option></option>
    <option>01</option>
    <option>02</option>
    <option>03</option>
    <option>04</option>
    <option>05</option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    </select>
    <select name = "ccAnno" id ="ccAnno">
    <option></option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    </select>
    /
    (month/year) </p></td>
    </tr>
    <tr>
    <td class="normale"><div align="right"></div></td>
    <td class="normale"><input name="ccTipo" type="radio" value="Mastercard" id="ccVisa"> [img]../images/master.jpg[/img] <input name="ccTipo" type="radio" value="Visa" id="ccMastercard"> [img]../images/visa.jpg[/img]</td>
    </tr>
    <tr>
    <td class="normale"></td>
    <td class="normale">Using a credit card will insure that your order will be processed at time of delivery. </td>
    </tr>
    </table>
    </div>




    <input name="ModPag" type="radio" value="Credit Card" id="carta" onClick="javascript:sblocca();">
    Credit Card

    <input name="ModPag" type="radio" value="Payment on delivery" disabled="disabled" id="contrassegno" onClick="javascript:sblocca();">
    Payment on delivery <span class="Stile2">(just for Italian shipping)</span>

    <input name="ModPag" type="radio" value="Bank transfer " id="conto" onClick="javascript:sblocca();">
    Bank transfer <span class="Stile2">read more

    <input name="ModPag" type="radio" value="Bookshop pick-up" disabled="disabled" id="ritiro" onClick="javascript:blocca();">
    Bookshop pick-up <span class="Stile2">(just for Italian shipping)</span></p>


    </p>


    Method of shipping:</p>



    <input name="ModSpe" type="radio" value="Express Courier" disabled="disabled" id="corriere" onclick="javascript:calcola();">
    Express Courier

    <input name="ModSpe" type="radio" value="Poste Italiane" disabled="disabled" id="poste" onclick="javascript:calcola();">
    Poste Italiane <span class="Stile2">(just for Italian shipping)</span>

    </p>


    </p>


    Change shipping zone:</p>


    Italy</p>


    Europe </p>


    </p>


    </p>


    </p>



    <input type="checkbox" name="accetto" value="accetto" id="accetto">
    Select to approve general conditions (necessary to go ahead with the order) and time of shipping.







    </p></td>
    <td height="100" align="right" valign="bottom"><input type="hidden" name="Ordina" value="si">


    </td>
    <td align="left" valign="bottom">

    &euro;.
    <input type="hidden" id="totale" value="<%=df.format(totale)%>">
    <%= df.format(totale) %>

    <span class="piccoloNormale">(cost of books) </span></p></td>
    </tr>
    <tr>
    <td height="50" rowspan="2" align="right" valign="top">

    </p> </td>
    <td align="left" valign="top">

    </p>


    &euro;.
    <input type="text" disabled="disabled" id="ss1" value="0" size="4" name="ss1">
    <input type="hidden" id="ss" value="0" size="4" name="ss">
    <span class="piccoloNormale">(shipping cost)</span></p>


    &euro;. <input type="text" disabled="disabled" id="totaless" value="<%= totale %>" size="4">
    <span class="piccoloNormale">(total)</span></p> </td>
    </tr>
    <tr>
    <td align="left" valign="bottom">
    <input name="button2" type="button" class="BottoneArancione80" onClick="javascript:checkOrdine();" value="Order">


    <span class="piccoloGrigino">(Final Confirmation. You will not allowed to change your order)</span>
    </td>
    </tr>
    </form>
    <% }
    if (Ordina.length() > 0) {
    %>
    <tr>
    <td></td>
    <td></td><td>
    <%
    if (ss > 0.00) {
    %>
    <p align="left"> &euro;. <%= df.format(ss) %> (shipping cost)</p>
    <%
    %><p align="left"> &euro;. <%= df.format(totale + ss) %> (total)</p>
    <%
    }
    %>
    </td></tr>
    <%
    Testo = Testo + "<tr><td></td><td></td><td>


    &euro;. "+ df.format((new Float(totale))) +" - costs of books";
    Testo = Testo + "</p></td></tr>";
    }
    if (Conferma.length() == 0 && Svuota.length() == 0) { %>
    <tr>
    <td colspan="3" align="left" valign="bottom">



    <%