How do I use currency converter to show new currency in html

Good day.

Need help on the following.

  1. I am getting BTC price from binnance with a stream (this part is working.)
  2. I have my script on currency converter to ZAR (working)
  3. I can display the price of BTC in my html.
  4. No I need to know on how to show the price in html for ZAR, some of the code is working, if I click on multiplay is is working.
  5. How can I make it that it will auto multiply (if I have only 1 BTC it must multiply from currency to ZAR and show show in in html)
  6. How can I make it also if I have more BTC (I can add it in JavaScript to auto multiply and show in html.
  7. It must use the price that I display at the moment, and the ZAR must then auto update to ne price.

it must show like this in html

1 BTC = to $2200.97777 1 BTC = t0 (if ZARr is at that moment R15.00 to 1$) R308325.0

<div class='col-2 p-5 me-5'>
                <div class='uit d-flex justify-content-end mb-3'>BTC</div>
                <div class='uit d-flex justify-content-end mb-3'>1 USD</div>
                <div id='show_price_binance_btc'><span>...</span></div>
                <div id="gcw_valFpWbgYyUL0">...</span></div>
            </div>
          
            <div class='col-2 p-5 me-5'>
               <td><input type="number1" id="firstNum1" name="firstNum1"></td>
                <td><label for="secondNum1">140,000.000111</label></b></td>
                <input style="visibility:hidden" type="number1" id="secondNum1" name="secondNum1"></td>
                <td><button type="button" onclick="multiply2()">Multiply</button></td>
                <td><input type="text" id="result3" name="result3"/></td>
                <input style="visibility:collapse" type="usdzar1" id="usd1" name="usd1">
                <label for="zar1"></label>
                <input style="visibility:collapse" type="usdzar1" id="gcw_valFnAj0a2vV1" name="zar1">
                <td><button type="button" onclick="multiply4()">Multiply</button></td>
                <td><input type="text" id="result4" name="result4"/></td>
            </div>
<script>
function multiply5(){
    var num9 = document.getElementById("firstNum2").value;
    document.getElementById("secondNum2").value = 0.00003390;
    var num10 = document.getElementById("secondNum2").value;
    var result5 = num9 * num10;
    document.getElementById("result5").value = result5.toLocaleString('en-US',{ maximumFractionDigits: 8 });
    document.getElementById("result5").style.color = "red";
    document.getElementById("result5").style.fontWeight = "900";
}
</script>
<script>
function multiply6(){
    var num11= document.getElementById("result5").value.replace(/,/g,''); //remove any commas
    var num12 = document.getElementById("gcw_valFnAj0a2vV1").value;
    var result6 = num11 * num12;
    document.getElementById("result6").value = result6.toLocaleString('en-US',{ maximumFractionDigits: 8 });
    document.getElementById("result6").style.color = "red";
    document.getElementById("result6").style.fontWeight = "900";
}
</script>
<script>

        $(document).ready( function () {
            $('#datatable').DataTable({
                "paging":   false,
                "searching": false,
            });
        } );


        $(document).ready(function() {
            var baseUSD = '<?=$baseUSD?>';
            var coin_rate_in_ZAR = '<?=$coin_rate_in_ZAR?>';
            var coin_rate_in_USD = '<?=$coin_rate_in_USD?>';

            $('#gcw_valFpWbgYyUL0').val(baseUSD);
            $('#gcw_valFpWbgYyUL1').val(coin_rate_in_ZAR);


            // When USD value changes
            $('#gcw_valFpWbgYyUL0').on('keyup',function(){
                var baseUSD = $('#gcw_valFpWbgYyUL0').val();
                var valueInZar = baseUSD * coin_rate_in_ZAR;

                // alert(valueInZar);
                $('#gcw_valFpWbgYyUL1').val(valueInZar);

                
            });


            // When ZAR value changes
            $('#gcw_valFpWbgYyUL1').on('keyup',function(){
                var baseZAR = $('#gcw_valFpWbgYyUL1').val();
                var valueInUSD = (baseZAR * coin_rate_in_USD).toFixed(4);

                // alert(valueInUSD);
                $('#gcw_valFpWbgYyUL0').val(valueInUSD);

            });

        });

    </script>

This is how I need it to be.

Screenshot_4

You’ll want to use the JavaScript Multiplication (*) to multiply the ZAR value by the qty of the BTC. So you would integrate [BTC qty] * [ZAR base value].

Thank you WebSteve

I ane quit new to javascript.

This is my line, where I get my info from.

 html_element_binance_shib.innerText = '↓ $ ' + price_binance_shib;

Did try to add it plus the zar, but is till only show USD. I know I are doing something wrong, and this is only still just to get the zar amount, not even have tried to add total amount of tokens.
Here is the code I have tried, and under it is my currency code.

if ((price_binance_shib < last_price_binance_shib) && (isNaN(price_binance_shib) == false)) {
        html_element_binance_shib.innerText = '↓ $ ' + price_binance_shib +  gcw_inputFpWbgYyUL + gcw_valFpWbgYyUL1;
<script>

        $(document).ready( function () {
            $('#datatable').DataTable({
                "paging":   false,
                "searching": false,
            });
        } );


        $(document).ready(function() {
            var baseUSD = '<?=$baseUSD?>';
            var coin_rate_in_ZAR = '<?=$coin_rate_in_ZAR?>';
            var coin_rate_in_USD = '<?=$coin_rate_in_USD?>';

            $('#gcw_valFpWbgYyUL0').val(baseUSD);
            $('#gcw_valFpWbgYyUL1').val(coin_rate_in_ZAR);


            // When USD value changes
            $('#gcw_valFpWbgYyUL0').on('keyup',function(){
                var baseUSD = $('#gcw_valFpWbgYyUL0').val();
                var valueInZar = baseUSD * coin_rate_in_ZAR;

                // alert(valueInZar);
                $('#gcw_valFpWbgYyUL1').val(valueInZar);

                
            });


            // When ZAR value changes
            $('#gcw_valFpWbgYyUL1').on('keyup',function(){
                var baseZAR = $('#gcw_valFpWbgYyUL1').val();
                var valueInUSD = (baseZAR * coin_rate_in_USD).toFixed(4);

                // alert(valueInUSD);
                $('#gcw_valFpWbgYyUL0').val(valueInUSD);

            });

        });

    </script>

I know it is not that hard to figure it out, but I just cannot do it.

Where do you do the multiplication?
What output are you getting?
(I don’t know JS very well either!)

I am not doing the multiplication at the moment, that is where I am stuck with it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.