Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <html class="no-js" lang="">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    body {
        padding-top: 50px;
        padding-bottom: 20px;
    <link rel="stylesheet" href="css/main.css">
    <script src="js/vendor/modernizr-2.8.3.min.js"></script>

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand center-block" href="#">Taxes</a>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div id="servicios" class="panel-body">
                        <div class="no-agrego"><span class="glyphicon glyphicon-pencil"></span> Add new service</div>
                    <div class="panel-footer">
                        <a id="agregar-valor" data-toggle="modal" data-target="#modalServ" class="btn btn-lg btn-default btn-block"> <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Add service</a>
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div id="impuestos" class="panel-body">
                        <div class="no-agrego"><span class="glyphicon glyphicon-pencil"></span> Add new tax</div>
                    <div class="panel-footer">
                        <a id="agregar-impuesto" data-toggle="modal" data-target="#modalImp" class="btn btn-lg btn-default btn-block"> <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Add tax</a>
                <div class="well">
                    <a id="calcular" class="btn btn-lg btn-primary btn-block"> <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> Calculate</a>
            <div id="genResultados" class="col-md-12">
        <!-- Modal  Servicio-->
        <div class="modal fade" id="modalServ" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">Add service</h4>
                    <div class="modal-body">
                        <div class="agrega-servicio">
                            <div class="form-group">
                                <label for="nombre-servicio">Service name</label>
                                <input type="text" class="form-control" id="nombre-servicio" placeholder="Ex: Logo Design">
                            <div class="form-group">
                                <label for="num-valor">Service value</label>
                                <input type="number" class="form-control" id="valor-servicio" placeholder="Ex: 40000">
                            <button type="submit" class="btn btn-primary" id="agrega-valor">Add</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <!-- Modal  Impuesto-->
        <div class="modal fade" id="modalImp" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">Add tax</h4>
                    <div class="modal-body">
                        <div class="agrega-impuesto">
                            <div class="form-group">
                                <label for="nombre-imp">Tax name</label>
                                <input type="text" class="form-control" id="nombre-imp" placeholder="Ex: VAT">
                            <div class="form-group">
                                <label for="num-imp">Tax value (%)</label>
                                <input type="number" class="form-control" id="num-imp" placeholder="Ex: 6">
                            <button type="submit" class="btn btn-primary" id="agrega-impuesto">Add</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <!-- /container -->
    <!--   <script src="//"></script> -->
    <script src="js/vendor/jquery-1.11.2.min.js"></script>
    <script src="js/vendor/bootstrap.min.js"></script>
    <script src="js/main.js"></script>




/* ==========================================================================
   Author's custom styles
   ========================================================================== */
	position: relative;
	min-height: 50px;
.no-agrego {
	padding: 16px;
    text-align: center;
    background-color: rgba(199, 224, 239, 0.86);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    line-height: 100%;



                // Services
var servicios = [
//  { nombre_servicio: 'Fotografia', valor: 40000 }, { nombre_servicio: 'Tarjetas', valor: 60000 }
var tablaServicios = 0;
var nS = document.getElementById('nombre-servicio');
var vS = document.getElementById('valor-servicio');
var botonAgregarServicio = document.getElementById('agrega-valor');

var impuestos = [
  //{ nombre_impuesto: 'Iva', valor: 6 }, { nombre_impuesto: 'ICA', valor: 2 }
var tablaImpuestos = 0;
var nI = document.getElementById('nombre-imp');
var vI = document.getElementById('num-imp');
var botonAgregarImpuesto = document.getElementById('agrega-impuesto');

//Calculate button
var botonCalcular = document.getElementById('calcular');

// Calculate Event on click
botonCalcular.addEventListener("click", calcularImpuestos);

//Add service
botonAgregarServicio.addEventListener("click", agregaServicio);

//Get input values and add to services array
function agregaServicio() {
        nombre_servicio: nS.value,
        valor: vS.value

    //Close modal    
    //Clear inputs 
    $('.agrega-servicio input').val('');

    //Get last item of services array
    var s = servicios[servicios.length - 1].nombre_servicio;
    var v = servicios[servicios.length - 1].valor;

    //Add table if not exist
    if (tablaServicios == 0) {

        var tabla = document.querySelectorAll('.servicios thead tr th');
        tabla[0].innerHTML = 'Nombre servicio';
        tabla[1].innerHTML = 'Valor servicio'

        agregaFila('.servicios', s,'$ ' + v);

        //Delete "add new service" overlay
        var el = document.querySelectorAll('#servicios .no-agrego');

        tablaServicios = 1;

    } else {
        agregaFila('.servicios', s,'$ ' + v);


//Add tax
botonAgregarImpuesto.addEventListener("click", agregaImpuesto);

//Get input values and add to taxes array
function agregaImpuesto() {
        nombre_impuesto: nI.value,
        valor: vI.value

    //Close modal     
    //Clear inputs
    $('.agrega-impuesto input').val('');

    //Get last item of taxes array
    var s = impuestos[impuestos.length - 1].nombre_impuesto;
    var v = impuestos[impuestos.length - 1].valor;

    //Add table if not exist
    if (tablaImpuestos == 0) {

        var tabla = document.querySelectorAll('.impuestos thead tr th');
        tabla[0].innerHTML = 'Nombre impuesto';
        tabla[1].innerHTML = 'Valor impuesto (%)'

        agregaFila('.impuestos', s,v + ' %');

        //Delete "add new tax" overlay
        var el = document.querySelectorAll('#impuestos .no-agrego');

        tablaImpuestos = 1;

    } else {
        agregaFila('.impuestos', s,v + ' %');


function calcularImpuestos() {

    if (servicios.length > 0 && impuestos.length > 0) {

        //Loop services array items
        for (var i = 0; i < servicios.length; i++) {

            //Results container
            var resultados = document.getElementById('genResultados');

            //Generate elements in DOM
            var contenedorTabla = document.createElement('div');
            var modulo = document.createElement('div');
            var h1 = document.createElement('h1');
            var tituloServicio = document.createTextNode(servicios[i].nombre_servicio);
            var panel = document.createElement('div');
            var panelBody = document.createElement('div');
            var panelFooter = document.createElement('div');
            var row = document.createElement('div');
            var col1 = document.createElement('div');
            var titR1 = document.createTextNode('Total');
            var col2 = document.createElement('div');

            //Add created elements into container

            //assign classes and id to elements
   = 'resultados-' + i + '-servicio';
            modulo.className = 'servicio-' + i;
            panel.className = 'panel panel-default';
            row.className = 'row';
            col1.className = 'col-md-6 col-xs-6';
            col2.className = 'col-md-6 col-xs-6';
            panelBody.className = 'panel-body';
            panelFooter.className = 'panel-footer';

            genera_tabla('resultados-' + i + '-servicio');

            //Add thead
            var tablaHead = document.querySelectorAll('.resultados-' + i + '-servicio thead tr th');
            tablaHead[0].innerHTML = 'Nombre impuesto';
            tablaHead[1].innerHTML = 'Valor del impuesto';
            //Array to store taxes results
            var mArray = []

            //Loop taxes array
            for (var j = 0; j < impuestos.length; j++) {
                var nombreImpuesto = impuestos[j].nombre_impuesto;
                //Tax value
                var k = impuestos[j].valor;

                //Service value
                var l = servicios[i].valor;

                //Math operation get percentage 
                var m = (k * l) / 100;
                //Add [m] result to array 
                //Add row to html results each tax name and value
                agregaFila('.resultados-' + i + '-servicio', nombreImpuesto,'$ ' + m);


            //Get service module
            var tablaBody = document.querySelectorAll('.resultados-' + i + '-servicio');

            //Sum all taxes per service            
            var sumaImpuestos = 0;

            for (var x = 0; x < mArray.length; x++) {
                sumaImpuestos += mArray[x];

            //Add result to dom
            var titR2 = document.createTextNode('$ ' + sumaImpuestos);


        //Delete calculate buton
        var el = document.querySelectorAll('.well #calcular');

    } else {
        alert('No hay valores para calcular');


function genera_tabla(id) {
    // Get container element
    var contenedor = document.getElementById(id);
    // Create element <table> and <tbody> <thead>
    var tabla = document.createElement("table");
    var tblBody = document.createElement("tbody");
    var thead = document.createElement('thead');
    var tr = document.createElement('tr');
    var thNombre = document.createElement('th');
    var thValor = document.createElement('th');


    // place <tbody> inside <table>    
    // place <table> inside container
    //Add bootstrap class to table
    tabla.className = 'table ' + id;

//Add row to table
function agregaFila(clase, nombre, valor) {
    //Get table
    var tabla = document.querySelectorAll(clase);
    //Insert row at the end of the table
    var fila = tabla[0].children[1].insertRow(-1);
    //Insert cell 1
    var celda1 = fila.insertCell(0);
    //Insert cell 2
    var celda2 = fila.insertCell(1);
    //Insert data from name
    celda1.innerHTML = nombre;
    //Insert data from value
    celda2.innerHTML = valor;