css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <form method="post" action="" id="payment-form" name="be2billForm" onsubmit="return tokenizeHandler()">

    <div id="card">
        
        <div id="bank-network">
            <label class="up">Bank network</label>
            <div class="fakeSelect">
                <ul id="bank-network-selector">
                </ul>
            </div>
        </div>
        
        <fieldset>
            <p>
                <label id="card-label" onclick="focusIframe('hosted-fields-frame-card');">Card number</label>
                <span class="input-container" id="card-container" onclick="focusIframe('hosted-fields-frame-card');"></span>
            </p>

            <p class="w1-2">
                <label id="expiry-label" onclick="focusIframe('hosted-fields-frame-expiry');">MM/YY</label>
                <span class="input-container" id="expiry-container" onclick="focusIframe('hosted-fields-frame-expiry');"></span>
            </p>

            <p class="w1-2">
                <label id="cryptogram-label" onclick="focusIframe('hosted-fields-frame-cryptogram');">Cryptogram <i id="crytogram-info" class="fas fa-question-circle" onclick="cryptogramAlert();" ></i></label>
                <span class="input-container" id="cryptogram-container" onclick="focusIframe('hosted-fields-frame-cryptogram');"></span>
            </p> 
        </fieldset>
    </div>

    <!-- This hidden input field will receive the token -->
    <input type="hidden" name="hf-token" id="hf-token">

    <p class="submit">
        <button class="droppable OFF" id="plop">Pay <span class="price">49.50</span><span class="symbol">€</span></button>
    </p>
</form>
<div id="info">
    <p><strong>This is a "sandbox environment" payment form: no actual bank movements will occur.</strong></p>
    <p>However, I cannot guarantee the confidentiality of the banking data entered on a Codepen interface, so <strong>DO NOT</strong> use real bank card data, please use instead one of these test cards:</p>
    <ul>
        <li>VISA: 4111 1111 1111 1111</li>
        <li>MasterCard: 5111 1111 1111 1118</li>
        <li>American Express: 3444 444444 44447</li>
        <li>Bancontact: 67777777777777775</li>
    </ul>
    <p>With any expiry date, and any 3 digits cryptogram.</p>
</div>
            
          
!
            
              body {
    width: 100%;
    height: 100%;
    background-color: #eee;
    font-size: 1.2em;
    perspective: 800px;
    perspective-origin: 50%;
    transition: background-color 0.5s ease;
}
body * {
    font-family: "Open Sans", "Century Gothic", "Calibri", "Trebuchet MS", Arial, Helvetica, sans-serif;
}

form {
    position: absolute;
    top: 42px;
    left: 50%;
    margin-left: -225px;
    width: 450px;
    transition: top 250ms ease-in-out, height 250ms ease-in-out;
}
#card {
    z-index: 1;
    position: relative;
    height: 160px;
    box-sizing: border-box;
    padding: 40px 90px;
    border-radius: 2px;
    background: white;
    box-shadow: 1px 1px 5px rgba(0,0,0,.1);
    transition: height 250ms ease-in-out, padding 250ms ease-in-out, border-radius 250ms ease-in-out, box-shadow 250ms ease-in-out, background-color 250ms ease-in-out;
}
form.up {
    top: 35px;
    height: 180px;
}
form.up #card {
    height: 260px;
    padding: 90px 80px 40px 80px;
}
#card:before,
#card:after {
    opacity: 0;
    transition: opacity 250ms ease-in-out;
}
form.up #card:before {
    content: '';
    z-index: 1;
    display: block;
    position: absolute;
    bottom: 0.75px;
    left: 0;
    width: 100%;
    height: 40px;
    border-bottom: 3px solid rgba(255,255,255,.75);
    border-radius: 20px;
}
form.up #card:after {
    content: '';
    z-index: 1;
    display: block; /* debug, delete me when brand selector is ON */
    display: none; /* debug */
    position: absolute;
    top: 10px;
    right: 10px;
    width: 80px;
    height: 40px;
    background-position: 50% 50%;
    background-size: contain;
    background-repeat: no-repeat;
}
form p {
    position: relative;
    height: 40px;
    transition: all 250ms ease-in-out;
}
form.up p:nth-last-child(n+2) {
    margin-bottom: 35px;
}
iframe { height: 40px; } /* FF iframe overflow hack */
.input-container,
.hosted-fields-valid-state.hosted-fields-focus-state {
    position: relative;
    display: inline-block;
    max-width: 100%;
    height: 40px;
    overflow: hidden;
    box-sizing: border-box;
    padding: 9px 7px 3px 7px;
    border: 1px solid #ddd;
    background: white;
}
#card-container {
    width: 100%;
}
#expiry-container,
#cryptogram-container {
    display: block; width: 100%;
}

.w1-2 {
    display: block;
    box-sizing: border-box;
    float: left;
}
.w1-2:nth-child(even) { width: 50%; }
.w1-2:nth-child(odd) { width: 50%; }

fieldset label {
    z-index: 1;
    position: absolute;
    padding: 10px 7px;
    left: 0;
    bottom: 0;
    cursor: text;
    transition: all 250ms ease-in-out;
}

label {
    display: block;
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    color: #bbb;
    font-style: italic;
    font-size: 90%;
}
label.up {
    padding: 0;
    bottom: 42px;
    height: 20px;
    font-size: 75%;
}
label #crytogram-info {
    display: none;
    opcatity: 1;
    vertical-align: middle;
    font-size: 1.2em !important;
    cursor: pointer;
}
label.up #crytogram-info {
    display: inline-block;
    opacity: 1;
}

.submit {
    position: absolute;
    top: 280px;
    left: 0;
    width: 100%;
    text-align: center;
    opacity: 0;
    transition: opacity 250ms ease-in-out;
}
form.up .submit { opacity: 1; }

button {
    width: 200px;
    height: 40px;
    background: #eee;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 1em;
    box-shadow: 0 2px 20px #ddd, 0 1px 2px #666, 0 0 20px white inset, 0 0 20px white inset;
    cursor: pointer;
    transition: background 250ms ease-in-out, box-shadow 250ms ease-in-out;
}
button .price,
button .symbol {
    font-weight: 600;
    color: #00a7d1;
    text-shadow: 0 0 2px white, 0 0 2px white;
}

button:hover {
    background: white;
    box-shadow: 0 2px 20px #ddd, 0 1px 2px #666;
}

button:after {
    content: "";
    z-index: 2;
    position: absolute;
    top: -50%;
    left: 50%;
    margin-left: -50px;
    width: 100px;
    height: 100px;
    border-radius: 15px;
    background-color: rgba(255,255,255,1);
    background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/contactless.svg);
    background-position: 50% 50%;
    background-size: 80% 80%;
    background-repeat: no-repeat;
    opacity: .25;
}
button.OFF:after {
    display: none;
}
/*button.ON:after,*/
button.ui-state-hover:after
{
    display: block !important;
}

#card.american_express,
#card.bancontact,
#card.maestro,
#card.mastercard,
#card.visa {
    background: #aaa;
    /*background-image: linear-gradient(to bottom, #ffffff 0%,#f1f1f1 50%,#e1e1e1 51%,#f6f6f6 100%);*/ /* light grandient */ 
    background-image: linear-gradient(to bottom, #ffffff 0%, #d1d1d1 50%, #c1c1c1 51%,#f6f6f6 100%); /* darker gradient */
    border-radius: 20px;
    box-shadow: 0 6px 6px 0 rgba(0,0,0,.25);
}

#card.american_express:before,
#card.bancontact:before,
#card.maestro:before,
#card.mastercard:before,
#card.visa:before,
#card.american_express:after,
#card.bancontact:after,
#card.maestro:after,
#card.mastercard:after,
#card.visa:after { opacity: 1; }

/*#card.american_express { background: #007cc3; }
#card.bancontact { background: #bd1922; }
#card.maestro { background: linear-gradient(115deg, #009ddd, #009ddd 50%, #ed1c2e 50%, #ed1c2e) }
#card.mastercard { background: linear-gradient(115deg, #d82332, #d82332 50%, #f1ad3d 50%, #f1ad3d); }
#card.visa { background: #0d4aa2; }*/

#card.american_express label,
#card.bancontact label,
#card.maestro label,
#card.mastercard label,
#card.visa label { color: black; }


#card.american_express:after { background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/american_express.svg); }
#card.bancontact:after { background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/bancontact.svg); }
#card.maestro:after { background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/maestro.svg); }
#card.mastercard:after { background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/mastercard.svg); }
#card.visa:after { background-image: url(https://sapereaude.io/codepen/RjLdaN/assets/visa.svg); }

.hosted-fields-focus-state {
    border: 1px solid turquoise; 
}
.hosted-fields-invalid-state {
    border: 2px solid red;
    animation-name: wriggle;
    animation-duration: 75ms;
    animation-iteration-count: 2;
    animation-direction: normal;
    animation-timing-function: linear;
}
.hosted-fields-valid-state {
    position: relative;
    border: 0;
    background: 0;
    overflow: visible; /* force the native hosted-field property */
}
.hosted-fields-valid-state:after {
    content: "\f00c";
    z-index: 1;
    display: block;
    position: absolute;
    top: -25px;
    width: 20px;
    height: 20px;
    font-family: "FontAwesome";
    font-weight: 300;
    color: #00a7d1;
    text-shadow: 1px 1px 0 rgba(255,255,255,.5), -1px -1px 0 rgba(0,0,0,.75);
}
#card-container.hosted-fields-valid-state:after {
    left: 90px;
}
#expiry-container.hosted-fields-valid-state:after {
    left: 50px;
}
#cryptogram-container.hosted-fields-valid-state:after {
    left: 100px;
}
.hosted-fields-disabled-state {
    background: 0;
    border: 0;
    overflow: visible; /* force the native hosted-field property */
}
.hosted-fields-disabled-state:after {
    content: "";
    z-index: 1;
    display: block;
    position: absolute;
    top: -14px;
    left: -2px;
    width: 80px;
    height: 1px;
    border-top: 1px solid white;
}

@keyframes wriggle {
    from { transform: translateY(-3px); }
    to { transform: translateY(0); }
}

/* hackh Chrome autofill style */
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
    background: inherit;
    color: inherit;
}

body #info {
    position: absolute;
    top: 380px;
    left: 50%;
	width: 500px;
    box-sizing: border-box;
    margin: 0 0 42px -250px;
    padding: 7px 14px;
    border-left: 1px solid red;
	line-height: 125%;
    text-align: justify;
    font-size: 11px;
    color: #999;
}
#info p+p,
#info p+ul,
#info ul+p {
    margin-top: .5em;
}
strong {
    font-weight: 600;
    color: #777;
}
#bank-network {
    display: none; /* debug */
    position: absolute;
    top: 3px;
    right: 3px;
    width: 80px;
    height: 40px;
    box-sizing: border-box;
    /*border: 1px solid green; /* debug */
}
#bank-network.active {
    display: block;
}
#bank-network > label {
    position: absolute;
    top: 12px;
    left: -95px;
    display: block;
    width: 100px;
    height: 30px;
    /*border: 1px solid orange; /* debug */
    /*text-align: right;*/
}

/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */

/* fake select style */
.fakeSelect {
	display: inline-block;
}

/* fix the ul and each li size */
.fakeSelect ul,
.fakeSelect ul li {
	display: block;
	width: 74px;
	height: 40px;
}

/* hide the list elements from the second one */
.fakeSelect ul {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden; 
}

/* select arrow on select header */
.fakeSelect ul:before {
	content: "";
	z-index: 1;
	position: absolute;
	top: 50%;
	right: 0;
	margin: -6px 5px 0 0;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 6px 0 6px 6px;
	border-color: transparent transparent transparent #000;
	cursor: pointer;
	opacity: .5;
	transition: opacity 100ms ease-in-out, transform 100ms ease-in-out;
	transform: rotate(0);
}

/* display the whole list */
.fakeSelect ul.active {
	overflow: visible;
}

/* select arrow on hover and active select header */
.fakeSelect ul:hover:before,
.fakeSelect ul.active:before {
	opacity: 1;
}

/* select arrow on active select header */
.fakeSelect ul.active:before {
	transform: rotate(90deg);
}

/* set the unselected list elements in second position */
.fakeSelect ul li {
	order: 2;
	text-align: left;
}

/*  selected list element on first position */
.fakeSelect ul li.active {
	order: 1;
	text-align: left;
}

/* list images style */
.fakeSelect ul li img {
	margin: 2px;
    max-width: 55px;
	height: 36px;
	box-sizing: border-box;
	opacity: .6;
	filter: grayscale(100%);
	transition: all 200ms ease-out;
}

/* list images style on hover or when selected */
.fakeSelect ul li.active img,
.fakeSelect ul li:hover img {
	opacity: 1;
	filter: grayscale(0);
}

/* display a pointer cursor on each list element */
.fakeSelect ul label {
	display: block;
	width: 100%;
	height: 100%;
	cursor: pointer;
}

/* hide radio */
.fakeSelect ul label > input {
  visibility: hidden; /* makes input not-clickable */
  position: absolute; /* remove input from document flow */
}
            
          
!
            
              /**
 * The purpose is to imitate the Material Design's floating labels effect.
 *
 * The input fields being hosted on an external page, outside the DOM, it is inconceivable to consider animating their placeholder attributes.
 * So you have to fake it, making labels look like placeholders.
 *
 *
 * We first need to detect the focus into the hosted-fields.
 * The difficulty lies in the fact that these fields are hosted in iframes, outside our DOM, therefore we can only base ourselves on 3 events:
 *     - When user is clicking or pressing a key
 *     - When focus is lost on the DOM
 *     - If the hosted-fields container's classes have changed, indicating that the focus is on one of them
 * Then, we could trigger an animation on the labels and apply a specific style on the containers
 */

bankNetwork =           document.getElementById("bank-network");
bankNetworkSelector =   document.getElementById("bank-network-selector");
fakeSelect = 		    document.getElementById("bank-network-selector");

// Detects the use of any key, and in particular the use of the TAB key to focus on a hosted-field
document.onkeydown = function(){
    formDynamics();
};

// Detects the use of the mouse
document.onclick = function(){
    formDynamics();
};

// Imitates Material Design input fields placeholder's animations
function formDynamics() {
    var paymentForm =       document.getElementById("payment-form");
    var cardField =         document.getElementById("card-container");
    var cardLabel =         document.getElementById("card-label");
    var expiryField =       document.getElementById("expiry-container");
    var expiryLabel =       document.getElementById("expiry-label");
    var cryptogramField =   document.getElementById("cryptogram-container");
    var cryptogramLabel =   document.getElementById("cryptogram-label");

    // Hold on 100ms before checking for the presence of a "focus" class on the hosted-fields containers
    setTimeout(function() {
        // If the focus is confirmed on any hosted-field...
        if( cardField.className.indexOf("hosted-fields-focus-state") > -1
            ||  expiryField.className.indexOf("hosted-fields-focus-state") > -1
            ||  cryptogramField.className.indexOf("hosted-fields-focus-state") > -1
        ) {
            // ...Then add classes to trigger animations
            paymentForm.classList.add("up");
            cardLabel.classList.add("up");
            expiryLabel.classList.add("up");
            cryptogramLabel.classList.add("up");
        }
    }, 100);
}

/**
 * Simulatse the <label> "for" attribute when clicking on the fake labels
 *
 * @param id
 */
function focusIframe(id)
{
    var iframe = document.getElementById(id);
    iframe.contentWindow.focus();
    return true;
}

// display a dialogbox with information about CVV
function cryptogramAlert()
{
    alert('CB | VISA | MasterCard : the last 3 digits on the back of the card.\n\nAmerican Express : the 4 digits on the front of the card.\n\nBancontact and some Maestro cards have no cryptogram.');
}

function isEmptyHostedField(elem)
{
    if(elem.className.indexOf("hosted-fields-empty-state") > -1) {
        return true;
    }
    return false;
}

// give a class to the form when a card type is detected
function formCustom(cardType)
{
    document.body.style.backgroundColor = "#ccc";
    var card = document.getElementById("card");
    card.className = cardType;
}

// manage a drag n drop effect to simulate a wireless payment when dropping a valid card on the payment button
$(document).ready(function(){
    $("#card").draggable();
    $( ".droppable" ).droppable({
        classes: {
            "ui-droppable-hover": "ui-state-hover"
        },
        drop: function( event, ui ) {
            var paymentForm = document.getElementById("payment-form");
            var cardField = document.getElementById("card-container");
            var expiryField = document.getElementById("expiry-container");
            var cryptogramField = document.getElementById("cryptogram-container");
            if( cardField.className.indexOf("hosted-fields-valid-state") > -1
                &&  expiryField.className.indexOf("hosted-fields-valid-state") > -1
                &&  cryptogramField.className.indexOf("hosted-fields-invalid-state") == -1
            ) {
                // play a sound
                var audio = new Audio('https://sapereaude.io/codepen/RjLdaN/assets/beep.ogg');
                audio.play();
                setTimeout(function() {
                    tokenizeHandler();
                }, 1000);
            }
        }
    });
});

// preload the sound to be played when using contactless payment
/**
 *
 */
function preloader(){
    var audio = new Audio('https://sapereaude.io/codepen/RjLdaN/assets/beep.ogg');
}
window.onload = preloader;

/**
 * Prepare the style to be used in the hosted-fields API call
 */
var style = {
    "input": {
        "background-color": "transparent",
        "font-size": "1.2em",
        "letter-spacing": "3px",
        "color": "#666"
    },
    ":valid": {
        "font-family": "consolas, system, sans-serif",
        "font-size": "1.5em",
        "color": "#eee",
        "text-shadow": "2px 2px 0 black, -2px 2px 5px black, -1px -1px 1px black"
    }
};

/**
 * Hosted-fields API Cal
 */
var hfields = dalenys.hostedFields({
    key: {
        /*id: "fadc44f6-b98b-4ea1-a8a0-50ab1d2e216f",
        value: "Gf=}k6]*E@EYBxau"*/
        /*id: "fadc44f6-b98b-4ea1-a8a0-50ab1d2e216f",
        value: "Gf=}k6]*E@EYBxau"*/
        id: "970c4f7c-c62e-40d2-8084-b61781326c81",
        value: "lr3*{F/4?nLnTq.t"
    },
    brandSelector: {
        id: 'brand-selector',
        isCbPreferredNetwork: 'visa',
        style: {
            "input": {
                "background-color": "yellow"
            },
            ":hover": {
                "background-color": "pink"
            }
        },
        onInput: function (event) {
            console.log('seleted brand received : ' + JSON.stringify(event));
            alert('toto');
        }
    },
    fields: {
        'card': {
            id: 'card-container',
            style: style,
            onBlur: function(event) {
                console.log(event);
            },
            onInput: function(event) {
                console.log(event);
                if(event.cardType) {
                    formCustom(event['cardType']);
                }
                //if(JSON.stringify(event.brands) !== '[]' && typeof JSON.stringify(event.brands) !== 'undefined') {
                if(JSON.stringify(event.brands) !== '[]') {
                    //console.log("y a de la brands: '"+JSON.stringify(event.brands)+"'"); // debug
                    bankNetwork.classList.add("active");
                    if(typeof JSON.stringify(event.brands) !== 'undefined') {
                        networkSelector(event.brands);   
                    }
                } else {
                    //console.log("y a PAS de brands: '"+JSON.stringify(event.brands)+"'");  // debug
                    bankNetwork.classList.remove("active");
                    bankNetworkSelector.classList.remove("active");
                    emptySelector();
                }
                // https://stackoverflow.com/questions/2631001/test-for-existence-of-nested-javascript-object-key
            }
        },
        'expiry': {
            id: 'expiry-container',
            //placeholder: 'MM/YY',
            style: style
        },
        'cryptogram': {
            id: 'cryptogram-container',
            placeholder: '',
            style: style,
            onInput: function(event) {
                console.log(event);
            }
        }
    },
    locale: 'fr'
});

/**
 * Generates and collects a token while submitting the payment form
 *
 * @returns {boolean}
 */
function tokenizeHandler() {
    hfields.createToken(function(result) {
        console.log(result);
        if (result.execCode == '0000') {
            // Add token to payment form request
            document.getElementById('hf-token').value = result.token;
            prompt("Generated token:", result.hfToken); // demo
            document.be2billForm.submit();
        } else {
            alert(result.execCode+': '+result.message);
        }
    });
    return false;
}

hfields.load();

/*
 * Get each returned brand
 */
function networkSelector(elems)
{
    console.log('JSON.stringify(elems): '+JSON.stringify(elems));
    /*elems.forEach(function(element) {
        addNetwork(element.brand);
    });
    
    /* UP */
    
    addNetwork(elems);
}

/*
 * Add an option for each brand
 */
function addNetwork(elems)
{
    i = 1;
    
    elems.forEach(function(element) {
        
        brand = element.brand;
        if(document.getElementById("bknk-"+brand.toLowerCase()) == null) {
        
        newOption = document.createElement("li"); 
        newOption.setAttribute("id", "bknk-"+brand.toLowerCase());
        if(i == "1") {
            newOption.classList.add("active");
        }
        
        newLabel = document.createElement("label");
        
        newInput = document.createElement("input");
        newInput.setAttribute("type", "radio");
        newInput.setAttribute("name", "bank-network");
        newInput.setAttribute("value", brand);
        if(i == "1") {
            newInput.checked = true;
        }
        
        newImage = document.createElement("img");
        newImage.setAttribute("alt", brand);
        
        switch (brand) {
            case 'visa':
                newImage.setAttribute("src", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/950358/2613271289c487badce3fbe921c07af8_visa.svg");
                break;
            case 'mastercard':
                newImage.setAttribute("src", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/950358/2613271289c487badce3fbe921c07af8_mc.svg");
                break;
            case 'cb':
                newImage.setAttribute("src", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/950358/2613271289c487badce3fbe921c07af8_cb.svg");
                break;
        }
        bankNetworkSelector.appendChild(newOption).appendChild(newLabel);
        newLabel.appendChild(newInput);

        if(i == "1") {
            newInput.checked = true;
        }
            
        newLabel.appendChild(newImage);
    } else {
        console.log("does this bank network already appear?: " + document.getElementById("bknk-"+elem.toLowerCase())); // debug
    }
    
    i++;
        
    });
    
    addEventsListeners(fakeSelect);
}

/*
 * Delete any HTML element's children
 */
function emptySelector()
{
    while(bankNetworkSelector.firstChild) {
        bankNetworkSelector.removeChild(bankNetworkSelector.firstChild);
    }
}

/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */
/* ********** */

function addEventsListeners(fakeSelect)
{
    fakeSelectOptions = fakeSelect.getElementsByTagName("li");
    inputs =			fakeSelect.getElementsByTagName("input");

    fakeSelect.setAttribute("onmousedown", 'selectToggle();');
    for(i = 0; i < fakeSelectOptions.length; i++) {
        fakeSelectOptions[i].setAttribute("onmousedown", 'selectOption(this);');
    }   
}

function selectToggle()
{
	fakeSelect.classList.toggle("active");
}

function selectOption(li)
{   
	// unselect everything
	for(i = 0; i < fakeSelectOptions.length; i++) {
		fakeSelectOptions[i].classList.remove("active");
	}
	for(i = 0; i < inputs.length; i++) {
		inputs[i].checked = false;
	}
	
	// select the clicked elements
	li.classList.add("active");
	inputToSelect = li.getElementsByTagName("input")[0];
	inputToSelect.checked = true;
}

// References:
// https://jsbin.com/image-instead-of-radio-button/5/edit?html,css,output
// https://developer.mozilla.org/fr/docs/Web/CSS/Disposition_flexbox_CSS/Ordonner_%C3%A9l%C3%A9ments_flexibles
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console