...

View Full Version : Auto copy to clipboard help



elite-fusion
02-23-2012, 08:30 PM
Hey guys, I have a small script that i made, pretty much just reads a database and the script automatically creates a list of links compared to the amount of rows in the database, thats all fine, BUT, is there anyway for me to make it so that once the link is clicked, it automatically copies to the clipboard what is in a specific column of that specific row?

Fou-Lu
02-23-2012, 08:32 PM
No. PHP is server side and carries no abilities to copy anything to a client clip board. I don't think it even has hooks for the server clipboard now that I think of it.
Assuming you mean your own clip board, this will be using javascript.

tangoforce
02-23-2012, 08:34 PM
Just to add to Fous reply, I think Flash can also access the users clipboard.

Fou-Lu
02-23-2012, 08:53 PM
Just to add to Fous reply, I think Flash can also access the users clipboard.

Yep, your right it should be.
To be more broad, you'll need a client side language, not a server side language to do this (although both Java and C# can do this as well, but I don't consider either as Server Side languages).

felgall
02-23-2012, 08:56 PM
Most client side languages will not have access to the clipboard either - for example JavaScript doesn't. JScript running in Internet Explorer can access the clipboard via an ActiveX control but only if that particular ActiveX is enabled.

elite-fusion
02-23-2012, 09:27 PM
Thanks guys, but still not quite sure where i should look...this is my code so far which does work perfectly fine for displaying a list of all the things that I would need but I need it so that when I click on the link which is in the last column, it pretty much copies the salescode into my clipboard


<?php

// load the configuration file.

include("page-configurator.php");

//load all news from the database and then OREDER them by newsid

//you will notice that newlly added news will appeare first.

//also you can OREDER by (dtime) instaed of (news id)

$result = mysql_query("SELECT * FROM salescode ORDER BY sitecode ASC",$connect);

//lets make a loop and get all news from the database

while($myrow = mysql_fetch_assoc($result))

{//begin of loop

//now print the results:

echo "<tr><td width=\"25%\" valign=\"top\" bgcolor=\"615B67\" class=\"news\" style=\"border-bottom:1px dashed #A49FA5;border-left:1px solid #A49FA5;padding-top:.5em;padding-left:.5em;padding-bottom:.5em;\" align=center><table align=center width=\"100%\"><tr><td align=left><font size=\"2px\" color=\"ffcc00\"><b>";

echo $myrow['sitecode'];

echo "</b></font></td></tr></table></td><td align=\"center\" width=\"50%\" valign=\"top\" bgcolor=\"615B67\" class=\"events\" style=\"border-bottom:1px dashed #A49FA5;\"><table align=center width=\"100%\"><tr><td width=\"50%\" class=\"events\" align=center><u>";

echo $myrow['salescode'];

echo "</u></td><td width=\"50%\" class=\"events\" align=left>";

echo $myrow['dealername'];

echo "</td></tr></table>";

echo "</td><td align=\"right\" width=\"25%\" valign=\"middle\" bgcolor=\"615B67\" style=\"border-right:1px solid #A49FA5;border-bottom:1px dashed #A49FA5;\"><a target=\"_blank\" href=\"https://testing.com/loadSiteInfo.do?branch=123&siteCode=$myrow[sitecode]\"><font size=\"2px\"><b>";

echo $myrow['sitecode'];

echo "</b></font></a>&nbsp;&nbsp;</td></tr>";

}//end of loop

?>

Serex
02-24-2012, 03:18 AM
I prefer making the user do the actual copy. Populate a hidden field with your PHP data, then using javascript you could call a function to display your text in an input box for the user to copy.


function copyText (sText) {
window.prompt ("Clipboard: Ctrl+C, Enter", sText);
}

tangoforce
02-24-2012, 08:32 AM
but I need it so that when I click on the link which is in the last column, it pretty much copies the salescode into my clipboard


As we've explained, there is no way in PHP that you can do this.

You need to look at CLIENT SIDE languages / tech such as javascript or flash.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum