0

This is what i have tried

<script type="text/javascript">
function myFunction(input2) {
    var input1 = document.getElementById('pinput2');
    var input3 = document.getElementById('pinput3');
    var paymethod = document.getElementById('pm');
      @php
        $price = round($rates->get_rate("<script>document.writeln(input2);</script>", $settings->s_currency,"price"), 3 );
    @endphp
 var c_price = '<?php echo $price; ?>';
 var calculated_price = input2.value/c_price;
 input1.value =  calculated_price;
 input3.value = calculated_price;
 paymethod.value = input2;
};

  function changecoin() {
    var crypto = document.getElementById("coinch");
    var coin = crypto.value;

    if (coin == "BTC") {
        myFunction("BTC");
    }
    if (coin == "ETH"){
        myFunction("ETH");
    }
    if (coin == "LTC"){
       myFunction("LTC");
    }
                
    }

    </script>

and i can not get the input2 to work inside my php code @php $price = round($rates->get_rate("<script>document.writeln(input2);</script>", $settings->s_currency,"price"), 3 ); @endphp

I am using Laravel to develop an app where the system get the value of BTC to naira as he/she types in the values in real time.

  • As PHP is run on your server, and Javascript is client side, you can not make them run like this. You would need an AJAX Request to transfer the Javascript / ClientSide to the Server / PHP Script, where you can work with the new value. – Tyralcori Jun 26 '20 at 08:35
  • It is not possible – John V Jun 26 '20 at 08:35

0 Answers0