0

Im using Clipboard.js to Copy the coin wallet address based on whichever coin icon is clicked however its not working

Spent 3 days on this

HEAD

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script>

BODY

    <script>
    $(document).on('click', 'a#donate', function(){
    // get month
    var val = $(this).data('id');
    if(val == 'BTC'){ var img = 'btc.png'; var coin='btc'; var name='Bitcoin'; var address='BTC ADDRESS'; var qrcode='btcqr.png';}
    if(val == 'ETH'){ var img = 'eth.png';var coin='eth';var name='Ethereum';var address='ETH ADDRESS'; var qrcode='ethqr.png'}
    if(val == 'XRP'){ var img = 'xrp.png';var coin='xrp';var name='Ripple';var address='XRP ADDRESS'; var qrcode='xrpqr.png'}
    if(val == 'LTC'){ var img = 'litecoin.png';var coin='ltc';var name='Litecoin';var address='LTC ADDRESS'; var qrcode='ltcqr.png'}
    $("#donatecoinicon").attr('src',img);
    $("#donatecoin").attr('value',coin);
    $("#address").attr('value',address);
    $("#donatecopy").attr('data-clipboard-text',address);
    $("#qrcode").attr('src',qrcode);
    $("#donatecoinname").html(name);
    });
</script>

There are different images for each coin, one here for an example Launches Modal and displays info from var values above based on what image is selected

<a href="#" id="donate" data-id="BTC" data-toggle="modal" data-target="#donatemodal" ><img src="btc.png" class="center-block img-responsive" style="height:40px"></a>

Modal Code The Input with the address in and the button to copy

 <div class="col-xs-2 pull-left text-center" style="text-align:center;">
  <img src="" id="donatecoinicon" height="40" class="center-block" >
  </div>
  <div class="col-xs-10 pull-right">

            <div class="input-group">
              <input id="address"  readonly type="text" style="width:100%;text-align:center">
              <button class="btn"  id="donatecopy">COPY</button>
              QR Code : <br>
      <img src="" class="img-responsive" id="qrcode" style="height:100px; width:100px"><br>          
            </div>

    </div>

All data is displayed correctly its just the copy thats not working

Chris Yates
  • 243
  • 3
  • 16

0 Answers0