我试图通过php从我的服务器获取图像,我想要onClick功能,但它不能正常工作以下是我的代码示例:
<?php
$conn = ftp_connect("myserver") or die("Could not connect");
ftp_login($conn,"username","password");
$images = ftp_nlist($conn,"folder");
$r = count($images);
for($i=0;$i<$r;$i++)
{
//echo " $images[$i] ";
echo"<img id= '$i' class = '' border='1' src='mysource' width='300' height='250'>";
echo "<button onClick= 'hide()'> Print </button>";
echo "<button> Email </button>";
echo "<button> Text Me </button>";
echo "</br>";
}
ftp_close($conn);
?>
以下是我的javascript代码
function hide()
{
var t = document.getElementById(x);
t.setAttribute(class, print);
}
当我点击我的打印按钮时,它甚至没有通过这个函数在.php文件中调用该函数。谢谢你的帮助。
答案 0 :(得分:0)
→试试这个:
echo "<script type='text/javascript'>function hide_it(){alert('Entering Function hide_it()?'); /*var t = document.getElementById(x); t.setAttribute(class, print);*/}</script>";
for($i=0;$i<$r;$i++)
{
//echo " $images[$i] ";
echo"<img id= '$i' class = '' border='1' src='mysource' width='300' height='250'>";
echo "<button type='button' onclick='javascript:hide_it()'> Print </button>";
echo "<button> Email </button>";
echo "<button> Text Me </button>";
echo "</br>";
}