Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

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

thehen

Coder
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

HTML:
<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>

JavaScript:
<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>

JavaScript:
<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 am not going to use your code - too many things are not defined. I'll give it in words.

You enter your amount of bitcoins and hit the calculate button. This calls a function. That function gets the bitCoinAmount, then gets the ZAR. It then removes the conversion factor for the currencies you want -Say US dollars and Euros.
You can display this if you want. You then multiply the two numbers bitcoinamount times USdollarConvertionFactor. and display that amount.
 
I am not going to use your code - too many things are not defined. I'll give it in words.

You enter your amount of bitcoins and hit the calculate button. This calls a function. That function gets the bitCoinAmount, then gets the ZAR. It then removes the conversion factor for the currencies you want -Say US dollars and Euros.
You can display this if you want. You then multiply the two numbers bitcoinamount times USdollarConvertionFactor. and display that amount.
Thank you old man,

This old man does not know a lot about JavaScript, busy leaning, so I unforcedly do not understand what you are saying I must do
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom