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.
3 Answers
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.
8 Comments
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 :)HTML5.. isnt good enough yet. Even Facebook denied html5-way of development and moves back to flash.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/
Comments
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
<input type="text" value="<?php echo $abc; ?>" />copy to clipboardkind of functionality. If so, it is not a foolproof method. See this - stackoverflow.com/questions/400212/…