Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    605

    aggiungere iva al totale

    ciao a tutti sempre su questo forum ho trovato un o script molto carino che mi permette di cambiare quantità del prodotto ed in automatico acnhe il prezzo, ora però volevo aggiungere un check perchè se l'azienda è italiana a quel totale devo aggiungere l' iva.
    Mi potete dare una mano?
    lo script è questo, stavo aggiungendo la funzione del check, ma non so come farla funzionare


    Codice PHP:

    <script>
    function $(
    id) {
       return 
    document.getElementById(id);
    }

    function 
    addPieces(campobylimite_inferiore) {
        var 
    pezzi campo.value;
        
    pezzi parseInt(pezzi10);
        if (
    isNaN(pezzi)) pezzi 0;
        
        
    pezzi += by;
        if (
    pezzi limite_inferiore) return;
        
        
    campo.value pezzi;
        
    calctot(campo.id);
    }

    function 
    calctot(campo) {
      var 
    res =  parseInt($(campo).value10) * parseFloat($('unitario_'+campo).innerHTML);
      $(
    'totale_'+campo).innerHTML = (Math.round(res 100)) /100;
    }


    function 
    myfunction(obj,campo){
        if (
    obj.checked)
        {
        
        
          
    //var ras =  parseInt($(campo).value, 10) * parseFloat($('unitario_'+campo).innerHTML);
          
    $('totale_'+campo).innerHTML =come fare;

          
         
        }
        else
        {
            
        }
    }

    </script>




    <table width="738" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="34%">[img]products.png[/img]</td>
        <td width="19%"></td>
        <td width="47%"></td>
      </tr>
      <tr>
        <td height="21" colspan="3"><hr></td>
        </tr>
      <tr>
        <td></td>
        <td colspan="2">[B]Munsingwear Shirt[/B]</td>
        </tr>
      <tr>
        <td>[img]djacket.gif[/img]</td>
        <td colspan="2">Show the caddies who's boss in this eye-catching tribute to leisure. This windshirt, with its 100% black suede nylon shell, V-neck collar, cuff, and waistband will kepp you toasty and warm on the links. It boasts side seam, and set-in pockets.</td>
        </tr>
      <tr>
        <td></td>
        <td>Price (EUR):</td>
        <td>
        
        
        &euro;
      <span id="unitario_articolo12">78.00</span> 
        
        
        </td>
      </tr>
      <tr>
        <td></td>
        <td>Qty:</td>
        <td>
        
                <!--    
                <INPUT name="QTY" size="8" value="1" align="right">
                -->
            <input type="text" id="articolo12" readonly="readonly" value="1"/>
    <input type="button" value="+" onClick="addPieces($('articolo12'), 1, 1)" />
    <input type="button" value="-" onClick="addPieces($('articolo12'), -1, 1)" />
        
        
        
        </td>
      </tr>
      <tr>
        <td></td>
        <td valign="top">Totale:</td>
        <td valign="top">
          
    <span id="totale_articolo12"></span> 
    <script>calctot('articolo12')</script>

        
        
        </td>
      
      
      </tr>
        <tr>
        <td></td>
        <td>Factory Italy 
    </td>
        <td valign="top"><label>
          <input type="checkbox" name="checkbox" id="checkbox" onClick="myfunction(this,'articolo12');" >
        </label>
        (If you are an 'Italian company must add 20% VAT)</td>
      </tr>

      
      
      <tr>
        <td></td>
        <td></td>
        <td><INPUT TYPE="Submit" Value="Purchase"></td>
      </tr>
    </table>
    </FORM> 

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    605
    un piccolo aiutino,,,, qualsiasi suggerimento è ben accetto

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    605
    ragazzi credo di essere vicino... sono riuscito ad aggiungere un checkbox "iva" che mi incrementa il valore del totale del 20%. Ora ho solo un problemino che se non ho flaggato l'iva non mi fa la somma in automatico aumentando la quantità...
    potete darmi un suggerimento...? la pagina è questa
    grazie

    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    HTML>
    <
    HEAD>
    <
    TITLE></TITLE>

    <
    script>
    function $(
    id) {
       return 
    document.getElementById(id);
    }

    function 
    addPieces(campobylimite_inferiore) {
        var 
    pezzi campo.value;
        
    pezzi parseInt(pezzi10);
        if (
    isNaN(pezzi)) pezzi 0;
        
        
    pezzi += by;
        if (
    pezzi limite_inferiore) return;
        
        
    campo.value pezzi;
        
    calctot(campo.id);
    }

    function 
    calctot(campo) {
        
        
        if (
    document.getElementById('check_'+campo)!=null)
        {

        if (
    document.getElementById('check_'+campo).checked)
        {
         
    //alert('IVA TRUE');
         
    var res =  parseInt($(campo).value10) * parseFloat($('unitario_'+campo).innerHTML);
         $(
    'totale_'+campo).innerHTML =((Math.round(res 100)) /100)*20/100+((Math.round(res 100)) /100)
        }
            
        }else{
            
        
    //alert('dddddddd');
        
        
    var res =  parseInt($(campo).value10) * parseFloat($('unitario_'+campo).innerHTML);
        $(
    'totale_'+campo).innerHTML = (Math.round(res 100)) /100;
        }
        
        

        
      
      
      }


    function 
    myfunction(obj,campo){
        
        if (
    obj.checked)
        {
            var 
    res =  parseInt($(campo).value10) * parseFloat($('unitario_'+campo).innerHTML);
            $(
    'totale_'+campo).innerHTML =((Math.round(res 100)) /100)*20/100+((Math.round(res 100)) /100)
        }
        else
        {
            var 
    res =  parseInt($(campo).value10) * parseFloat($('unitario_'+campo).innerHTML);
            $(
    'totale_'+campo).innerHTML =((Math.round(res 100)) /100)
        }
    }





    function 
    validate(formObj,campo){
        
        
        
    formObj.iva.value=document.getElementById('check_'+campo).checked;
        
    formObj.totale.value=$('totale_'+campo).innerHTML;
        
    formObj.descrizione.value=$('descr_'+campo).innerHTML;
        
    formObj.qty.value=document.getElementById(campo).value;
        
    formObj.unitario.value=$('unitario_'+campo).innerHTML;
        
    //formObj.submit();
        
        
        
        
    return true;
    }













    </script>


    <FORM name="form1" ACTION="details.php" METHOD="POST">

      <input type="hidden" name="SKU"   value="ACI-203">
      <input type="hidden" name="NAME"  value="Munsingwear Shirt">
      <input type="text" name="totale" value="">
      <input type="text" name="descrizione" value="">
      <input type="text" name="iva" value="">
      <input type="text" name="qty" value="">
      <input type="text" name="unitario" value="">
      
    <table width="738" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="34%">[img]products.png[/img]</td>
        <td width="19%"></td>
        <td width="47%"></td>
      </tr>
      <tr>
        <td height="21" colspan="3"><hr></td>
        </tr>
      <tr>
        <td></td>
        <td colspan="2">[B]
        

        <span id="descr_articolo11">
        Lettore A
        </span>
        
        [/B]</td>
        </tr>
      <tr>
        <td>[img]zimages.jpeg[/img]</td>
        <td colspan="2">aaaaaaaaaaa</td>
        </tr>
      <tr>
        <td></td>
        <td>Price (EUR):</td>
        <td>
        
        
       &euro;
      <span id="unitario_articolo11">33.00</span> 
        
        
        </td>
      </tr>
      <tr>
        <td></td>
        <td>Qty:</td>
        <td>
        
                <!--    
                <INPUT name="QTY" size="8" value="1" align="right">
                -->
    <input type="text" id="articolo11" name="articolo11" readonly="readonly" value="1"/>
    <input type="button" value="+" onClick="addPieces($('articolo11'), 1, 1)" />
    <input type="button" value="-" onClick="addPieces($('articolo11'), -1, 1)" />
        
        
        
        </td>
      </tr>
      <tr>
        <td></td>
        <td valign="top">Totale:</td>
        <td valign="top">
      

      
    <span id="totale_articolo11"></span>
    <script>calctot('articolo11')</script>
      

      </td>
      
      
      </tr>
      
      
      
       <tr>
        <td></td>
        <td>Factory Italy 
    </td>
        <td valign="top"><label>
        <input type="checkbox" name="check_articolo11" id="check_articolo11" onClick="myfunction(this,'articolo11');" >
        </label>
        (If you are an 'Italian company must add 20% VAT)</td>
      </tr>
      
      
      <tr>
        <td></td>
        <td></td>
        <td>
        
        <INPUT TYPE="button" Value="Purchase" onClick="javascript:return validate(document.form1,'articolo11')">
        
        </td>
      </tr>
    </table>

    </FORM>



    </BODY>
    </HTML> 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.