Identify type of operation with javascript

1

How can I identify when the click is "From:" "To:"?

I have a code to add a value from a database field, to another field, follow the example:

HTML:

<div class='row justify-content-center'>
                        <div class="converter-field d-flex flex-column flex-md-row align-items-center mt-3 mb-3">
                            <div class="form-group calc" id="currencyBox1">
                                <span class="calc-symbol-box center" data-target="converter.fromSymbol">Disponível</span>
                                <input type="text" name="balancel_disponivel" id="balance_disponivel" placeholder="Digite o valor" class="form-control valor" />
                            </div>  

                            <i class="fa fa-exchange text-xl text-lg-2xl m-3 currency-swap" onclick="swapCurrencies();return false;"></i> 

                            <div class="form-group calc" id="currencyBox0">
                                <span class="calc-symbol-box center" data-target="converter.toSymbol">Especial</span>
                                <input type="text" name="balance_special" id="balance_especial" placeholder="Digite o valor" class="form-control valor" />
                            </div>
                            <div class="clearfix"></div>
                        </div>

                        <div class="clearfix"></div>
                    </div>

Javascript:

function fillData(a) {
    var d = document.location.href, c = d.match(/\#([A-Z]{3,5})/);
    if (c && c.length > 1) {
        var b = gt("currencyBox1");
        if (!a && b && b.innerHTML.indexOf(c[1]) != -1) {
            swapCurrencies()
        }
    }
    c = d.match(/\#([A-Z]{3,5})=([\-0-9\.eE]+)/);
    if (c && c.length > 2) {
        frm()[c[1]].value = c[2];
        cvrt(frm()[c[1]], !a)
    }
}
function frm() {
    return document.currency.elements
}
function gt(a) {
    return document.getElementById(a)
}
function swapCurrencies() {
    var b = gt("currencyBox0");
    var a = gt("currencyBox1");
    var e = gt("currencyText0");
    var d = gt("currencyText1");
    if (b && a && e && d) {
        var c = b.innerHTML;
        b.innerHTML = a.innerHTML;
        a.innerHTML = c;
        c = e.innerHTML;
        e.innerHTML = d.innerHTML;
        d.innerHTML = c
    }
    fillData(true)
}

I want to pass a parameter to identify, from which field I have to send, to be able to do this exchange of values.

For example, when I click on the button to make the field change, I wanted a parameter stating that the first field is just the field that I'll be debugging the value to add to the other.

    
asked by anonymous 05.06.2018 / 22:14

0 answers