View Full Version : Onclick: Prompt pulling data within an Array

01-30-2010, 03:40 AM
Hi.. I should warn, i know almost nothing about javascript. . i've been trying read sample scripts and examples on how to modify this script; but I just don't know enough.

I have a script that pulls data from an array, and copies it directly to the clipboard when a user clicks on it. The problem is this only works in IE, because Firefox doesn't by default allow that to happen. I'm trying to change it so that when it is clicked, instead, it takes what was going to be copied to the clipboard, and puts it in a Prompt box for the user to copy and paste. I had other scripts that do that, but I can't for the life of me figure out how to learn from it!

This is the function in the current script

<script language="javascript" type="text/javascript">
function selectThis(src) {
txt = eval(src +".innerText");
theObj = document.all(txt);
txtRange = document.body.createTextRange();
alert(txt + " '.$caption[ 'paste' ].'");

and this is the onclick code


foreach ( $ausgabe as $key => $data) {
if ( $key == '' )
if ( ( $_GET[ 'group' ] != '*' )
&& ( $this->info[ $key ][ 'xx_data' ] != $_GET[ 'group' ] ) )

$tpack = $this->info[ $key ][ 'pack' ];
$tname = $this->info[ $key ][ 'xx_desc' ];
$jsid= $nick2.'_'.$tpack;

if ( isset( $this->info[ $key ][ 'xx_lock' ] ) ) {
if ( $this->hide_locked > 0 )
$tname .= ' (gesperrt)';
$tname = htmlspecialchars( $tname);
if ( $javascript > 0 ) {
$tname = '<span class="selectable" onclick="javascript:selectThis(\''.
'<span id="'.$jsid.'" class="hidden">'.
'/msg '.$this->nick.' xdcc send '.$tpack."</span>\n";
if ( isset( $this->info[ $key ][ 'xx_note' ] ) )
$tname .= '<br>'.$this->info[ $key ][ 'xx_note' ];

$label = "Download mit:\n/msg ".$this->nick.' xdcc send '.$tpack."\n";
if ( isset( $this->info[ $key ][ 'xx_md5' ] ) )
$label .= " \nmd5: ".$this->info[ $key ][ 'xx_md5' ];
if ( isset( $this->info[ $key ][ 'xx_crc' ] ) )
$label .= " \ncrc32: ".$this->info[ $key ][ 'xx_crc' ];

echo '
<td class="right">#'.$tpack.'</td>
<td class="right">'.$this->info[ $key ][ 'xx_gets' ].'</td>
<td class="right">'.makesize($this->info[ $key ][ 'size' ]).'</td>
<td class="content" title="'.$label.'">'.$tname.'</td>

I've spent days at trying to customize it.. but.. i'm not a programmer :(

I was able to get it to open a prompt box, and had it populate with ("copy this code", $variable), but cannot figure out how to have it display the proper values that was clicked on. I have no idea though what is considered efficient either in the code.

I hope this isn't considered asking for TOO much help....

01-30-2010, 10:40 AM
what does the "onclick code" looks like in the browser?

PS. your code won’t run in Firefox and Safari.

01-30-2010, 07:46 PM
what does the "onclick code" looks like in the browser?

PS. your code wonít run in Firefox and Safari.

right now, it just says that "/msg botname xdcc send 1 has been copied in your clipboard" if you click on pack 1 (botname replaced with the name of the bot). It automatically copies it to the clipboard. Since it doesn't work in Firefox and Safari (which i know).. i want to change it to take what it was copying to the clipboard so that it opens a window up (small window) so that you can copy it yourself to the clipboard using ctl-c.

the botname is a variable as is the pack #. /msg xdcc send is constant.

01-30-2010, 08:29 PM

01-30-2010, 09:37 PM
sorry - maybe I'm not understanding what you are asking?

01-30-2010, 10:51 PM
I didnít understand any of your explanation, since it had nothing to do with either PHP or any code you posted (as far as I can tell).

01-31-2010, 12:32 AM
Here is a sample website that is using a similar code (its not mine, as mine isn't on the internet yet.. its local)..


Click on a pack i the list.. Try it in IE, then try in Firefox.. In IE, it copies directly to the clipboard (after first prompting for 'allow access'). In Firefox - nothing happens. Firefox doesn't allow direct clipboard access.

This is a sample of what I'm trying to get to with my script - if you click on a packlist, you'll see it opens a prompt.


See how when you click on the pack list, it prompts. I'm trying to modify my code, so that it prompts, rather than direct access.

01-31-2010, 12:34 AM
unfortunately (well, not that I would miss IE anyhow), there is no IE for darwin.