0

I am able to copy from textbox but i have a html form which contains field names and values. Below image has the sample form.enter image description here

When i click on copy to clipboard and paste, it should print the following : -

***** Customer Details *****
Name : JOHN
City : DELHI

As screenshot shows, i want to copy form data to clipboard

Any help much appreciated. Thanks in advance.

Shan
  • 295
  • 1
  • 5
  • 16

1 Answers1

0

This does not copy value, but get the value from the inputs and print it into the console.

To copy it. Take a look at this link or you can use this plugin clipboardjs

$('#Ctc').click(function() {
  var name = $('#Name').val()
  var City = $('#City').val()
  
  var ret = "***** Customer Details ***** \n\r Name : "+name+" \n\r City : " + City;
  console.log(ret)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>



<input placeholder="Name" id="Name"></input>
<input placeholder="City" id="City"></input>
<button id="Ctc">Copy to clipboard</button>
Carsten Løvbo Andersen
  • 26,637
  • 10
  • 47
  • 77