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.

3
  • 1
    It sounds like you want javascript, not php. Commented Nov 28, 2012 at 8:22
  • 3
    <input type="text" value="<?php echo $abc; ?>" /> Commented Nov 28, 2012 at 8:23
  • I think what you need is a copy to clipboard kind of functionality. If so, it is not a foolproof method. See this - stackoverflow.com/questions/400212/… Commented Nov 28, 2012 at 8:27

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

8 Comments

What about the JS part? No example for that?
JS solutions dont work good. So mostly flash objects are used for that.
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
@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 :)
@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.
|
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/

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.