Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Jeesun Kim
Jeesun Kim
4,866 Points

2 Text Boxes, With Copy + paste buttons

Hi,

Does anybody know of a code that can basically show two text boxes, text box #1 with certain words in it and then a "copy" button below it, copying the text in text box #1, and then with an additional text box option with a "paste" button below it, so that you can paste the text from box #1 to box #2?

It would be of tremendous help! Thank you in Advance!!!

2 Answers

The only way to access the clipboard across most browsers is through Flash. Depending on your browser/platform requirements, something like this may work: http://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard

From what you're describing though, you can 'cheat' it to create that effect. (assuming you don't actually need the clipboard). Here's an example I cooked up in javascript: http://jsfiddle.net/LWY2S/

The above example would work with a local cookie as well if you need to hang onto the 'copy' for a while.

Like Neal said, the only way to have something work across browsers is Flash.

ZeroClipboard is a simple way of doing this.

https://github.com/zeroclipboard/zeroclipboard