php - 如何查找单击了哪个“a”html元素
问题描述
这个 php 文件查找每个“.html”文件和“.txt”文件,并创建一个动态表,其中包含指向另一个页面的链接。在那个页面中,我想在一个框架中显示单击的 html 文件。
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>
<?php
echo '<h2>Escolha o Esquema de MetaDados a utilizar</h2>';
echo '<table cellspacing="0" cellpadding="0" border="0" class="table">';
echo '<tr>';
echo '<th>Esquema de MetaDados</th>';
echo '<th>Descrição</th>';
echo '</tr>';
foreach (glob("Templates/Dinamico/*.html") as $filename) {
foreach(glob("Templates/Dinamico/*.txt") as $txtname){
$fileH= basename($filename,".html");
$fileT= basename($txtname,".txt");
if($fileH==$fileT){
$txt= file_get_contents ( $txtname);
if($filename != "Templates/Dinamico/formD1.html"){
echo'<tr>';
echo'<td>';
echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php'>".$fileH."</a>";
echo'</td>';
echo'<td>';
echo $txt;
echo'</td>';
echo'</tr>';
}
}
}
}
?>
</body>
</html>
该文件是上面设置的链接页面,单击的 a 元素会填充 iframe,并将名称分配给“a”元素。
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>
<div>
<?php
This $a var i want to be the $fileH clicked on
echo '<iframe src="' .$a.'" frameBorder="0" width="70%" height="100%" align="left" scrolling="no" />';
echo '</iframe>'
?>
</div>
</body>
</html>
解决方案
推荐阅读
- amazon-web-services - 如何在 AWS 上使用自动扩缩器扩展 GPU 节点
- linux - C++ Linux - 后台进程在键盘按键处停止
- react-native - 滚动在 ScrollViews 组合中过早结束 - React native
- python - 每个 start_url 我们必须创建一个输出 CSV 文件
- css - 具有圆形边缘的背景颜色
- mysql - Yii2 迁移以增加列长度
- c# - 使用反射时检查 null
- python - Django 中的异常错误。创建超级用户后无法登录管理员
- html - 如何覆盖 PrimeNG 的
标记默认样式 - reactjs - Map React JS:用列显示数据