Search code examples
phpbitcoin

PHP result as variable in text / element field (use php output in 'placeholder' field)


I am loading the current bitcoin price to my webpage using:

var auto_refresh = setInterval(
     function()
     {$('.btc-price').load('gox.php');}, 10000);

I can get the current price to display with:

<div class="btc-price"></div>

But I want to use the price as a 'placeholder' in an input field:

<input placeholder="[current bitcoin price here]" />

Is this possible?


Solution

  • You can provide an id to your input field and then set the attribute placeholder through jquery.

    var auto_refresh = setInterval(
         function()
         {$.get('gox.php', function (data) {
              $("#inputid").attr('placeholder', data);
         });}, 10000);