Solved

ZeroClipboard not working after php processes the page

Posted on 2011-03-22
1
544 Views
Last Modified: 2012-05-11
I'm using php to dynamically create rows based on values from a database. At the end of each row I want to include functionality to copy the contents of that row to the clipboard.

I have working copy-to-clipboard code here:
		                        <script language="JavaScript">
						function cboard(text)
						{
                        var clip = new ZeroClipboard.Client();
						clip.setText(text);
                        clip.glue( 'd_clip_button' );
						}
                </script>
<script type="text/javascript" src="ZeroClipboard.js"></script>
                <div id="d_clip_button" onMouseOver="cboard('party');" style="border:1px solid black; padding:20px;">Copy To Clipboard</div>
                        

Open in new window


however, when I process it via php and output the page like so:


			$result = mysql_query("SELECT * FROM `backup` ORDER BY `id` ".sort_order()." LIMIT ".($logspage*$_SESSION["page"])." , ".$logspage.";", $mysql);
			if (!$result) die(mysql_error());
			
			$html .= "Logs".$header.$javascript."
					<form name='frm' method='POST' action='?action=selected' onsubmit='return checkform();'>
					<table id='logstable' cellpadding='2' cellspacing='0' border='0'><tr id='row0'>
					<td><a href='?action=logs&sort=0'>name/ ref</a></td>
					<td><a href='?action=logs&sort=1'>date</a></td><td><a href='?action=logs&sort=2'>password</a></td>
					<td><a href='?action=logs&sort=3'>website</a></td><td><a href='?action=logs&sort=4'>ip</a></td>
					<td><input type='checkbox' name='check_all' onClick='checkAll();'></td></tr>";
			$i = 0;
			while ($row = mysql_fetch_array($result)) {
				$html .= "<tr class='";
				if ($i % 2 == 0) $html .= "row1"; else $html .= "row2";
				$html .= "'><td>".$row["ref"]."</td>";
				$html .= "<td>".$row["name"]."</td><td>".$row["pass"]."</td><td>".$row["ip"]."</td>";
				$html .= "<td>".$row["date"]."</td>";
				$html .= "<td><input type='checkbox' name='sel[]' value='".$row["id"]."'><div id=\"d_clip_button\" onMouseOver=\"cboard('".$row["website"]."');\"><b>Copy</b></div></td></tr>";
				$i++;
			}

Open in new window


a working ZeroClipboard element is ONLY included on the FIRST ROW. all subsequent rows below the first are just plain-text "Copy" without the underlying necessary element that ZeroClipboard creates.

Does ZeroClipboard work like this? Or is it limited to only statically created pages? Or am I just doing something wrong in my dynamic ZeroClipboard implementation?


Thank you!
0
Comment
Question by:JoeD77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
Shinesh Premrajan earned 500 total points
ID: 35204531
actually there aer multiple creation of the tag "d_clip_button" hence the script confuses which one to use.

Below we have added a number to the d_clip_button tag which make it unique in the page

Hope this helps
<script language="JavaScript">
function cboard(text,id)
{
  var clip = new ZeroClipboard.Client();
       clip.setText(text);
       clip.glue( 'd_clip_button_'+id);
}
</script>


<div id=\"d_clip_button_$i\" onMouseOver=\"cboard('".$row["website"]."',$i);\">

Open in new window

0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question