2

I have $abc = "http://somewebsite.com/somefile.jpg". How do I show this URL in an input box so that the user can easily copy the link with a single click? Thanks everyone in advance.

dda
  • 5,700
  • 2
  • 23
  • 33

3 Answers3

2

Standart input: $input = "<input type='text' value='$abc' />"

If you want copy it by click - you need swf/js. But you can look this question for such solution.

Community
  • 1
  • 1
stasgrin
  • 126
  • 6
  • What about the JS part? No example for that? – asprin Nov 28 '12 at 08:26
  • JS solutions dont work good. So mostly flash objects are used for that. – stasgrin Nov 28 '12 at 08:27
  • flash is a dieing technology, and will not be natively supported in the near future, i would stay away from flash unless there is no other method of accomplishing your goals – Eyal Alsheich Nov 28 '12 at 08:38
  • 1
    @relentless I dont said it's better. But you are right, flash is `better` way coz it works in all browsers and in 100% cases. JS.. have many troubles with it and single solution for single browser. Read my link please and find out lot of new :) – stasgrin Nov 28 '12 at 08:38
  • 1
    @EyalAlsheich All are saying that flash dies (and i agree with that mostly).. but it still alive. And `HTML5`.. isnt good enough yet. Even Facebook denied `html5`-way of development and moves back to flash. – stasgrin Nov 28 '12 at 08:40
  • @relentless "Mark Zuckerberg: Our Biggest Mistake Was Betting Too Much On HTML5". Read this: [news post](http://techcrunch.com/2012/09/11/mark-zuckerberg-our-biggest-mistake-with-mobile-was-betting-too-much-on-html5/) – stasgrin Nov 28 '12 at 08:46
  • He was referring to their mobile app. It's now done naively, not in Flash. – Paul Dessert Nov 28 '12 at 08:47
  • @relentless so dont say Flash is bad. This thecknology has great and wide field of use. – stasgrin Nov 28 '12 at 08:48
0

The copying is mostly done in Flash, most browsers do not allow to access the clipboard from javascript for security reasons. You will need to pass the data to be copied to Flash, and place it inside the clipboard from there on.

Maybe this can help you: http://code.google.com/p/zeroclipboard/

Gerrit Bertier
  • 3,227
  • 1
  • 16
  • 27
0

You can put your URL in a input box like this before the page has rendered....

file.php

<?php
  $abc = "http://somewebsite.com/somefile.jpg";
?>
<input type="text" name="someURL" value="<?php echo $abc;?>" />

OR file.php

<?php
  $abc = "http://somewebsite.com/somefile.jpg";
  echo "<input type=\"text\" name=\"someURL\" value=\"".$abc."\" />";
?>

As for the copying - fiddly stuff

Chris
  • 4,976
  • 1
  • 24
  • 29