Last active
February 13, 2019 12:25
-
-
Save arkenidar/41e1783d29be84f5de18b3bcafaae432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html><html><head> | |
| <meta charset="utf-8"><title></title> | |
| </head><body> | |
| <form name="fattura_form"><input type="submit"></form> | |
| <template id="template_fattura"> | |
| <fieldset class="fatture"> | |
| quantita | |
| <input type="text" name="qta[]" value="1"> | |
| prezzo unitario | |
| <input type="text" name="prezzou[]" value="10"> | |
| aliquota | |
| <select name="select_iva[]" onchange="calcola(this.parentNode)"> | |
| <option value="20">22%</option> | |
| <option value="10">10%</option> | |
| <option value="4">4%</option> | |
| </select> | |
| totale parziale <input type="text" name="totale_parziale[]"> | |
| imponibile <input type="text" name="imponibile[]"> | |
| iva <input type="text" name="iva[]"> | |
| totale ft <input type="text" name="totale_fattura[]"> | |
| </fieldset> | |
| </template> | |
| <script> | |
| for(var i=0;i<5;i++) document.all.fattura_form.appendChild(document.all.template_fattura.content.cloneNode(true)) | |
| for(fattura_form of document.querySelectorAll('.fatture')) calcola(fattura_form) | |
| function calcola(elemento_fattura){ | |
| function field(field_name){ return elemento_fattura.querySelector('[name="'+field_name+'[]"]')} | |
| var quanti = field('qta').value | |
| var prezzo_unitario = field('prezzou').value | |
| var totale_parziale = quanti * prezzo_unitario | |
| var imponibile = totale_parziale | |
| var aliquota = field('select_iva').value | |
| var iva = (imponibile * aliquota) / 100 | |
| var totale_fattura = imponibile + iva | |
| field('totale_parziale').value = totale_parziale | |
| field('imponibile').value = imponibile | |
| field('iva').value = iva | |
| field('totale_fattura').value = totale_fattura | |
| } | |
| </script> | |
| <style> | |
| input[type=text] {width: 5em;} | |
| </style> | |
| </body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment