Php 打开弹出窗口后,内容将刷新

Php 打开弹出窗口后,内容将刷新,php,html,Php,Html,我有一个表单,其中有多个字段。我有一个按钮“获取报告”。按下此按钮后,表格中会显示所需的内容。在表格中,我有一个名为“图像”的列,它是指向图像的链接。当我按下链接时,图像会弹出。我的问题是,单击弹出窗口时,图像会出现,但页面会刷新。我希望即使在打开和关闭弹出窗口后,它仍保持在同一页面上 这是我的表,值是从数据库中提取的 <table id="sourceAnalysisTable" > <thead id="headings">

我有一个表单,其中有多个字段。我有一个按钮“获取报告”。按下此按钮后,表格中会显示所需的内容。在表格中,我有一个名为“图像”的列,它是指向图像的链接。当我按下链接时,图像会弹出。我的问题是,单击弹出窗口时,图像会出现,但页面会刷新。我希望即使在打开和关闭弹出窗口后,它仍保持在同一页面上

这是我的表,值是从数据库中提取的

 <table id="sourceAnalysisTable" >
                <thead id="headings">
                    <tr>
                        <td ><h3>Reported Date<h3></td>
                        <td><h3>Status<h3></td>
                        <td><h3>Address</h3></td>
                        <td><h3>Images<h3></td>
                    </tr>
                </thead>
                <tbody>
                <?php
                for($i=$start;$i<$end;$i++)
                    {


                        $dmydate = date('d-m-Y',strtotime($ARRAY[$i]['source_visitDate']));
                        echo'<td>'.$dmydate.'</td>';
                        echo'<td>'.$ARRAY[$i]['source_status'].'</td>';
                        echo'<td>'.$ARRAY[$i]['source_address'].'</td>';
                        echo'<td>';

    ?>
    /*here image names are given as link and #openModal is id to  popup*/
    <a href="?source_id=<?php echo $ARRAY[$i]["source_id"] ?>&#openModal" ><?php echo $ARRAY[$i]["source_photo"] ?> </a>

        <?php
    echo '</td>';
    echo'</tr>';

    }
/*get report button*/
<input type="submit" name="GETREPORT" value="Get Report" id="btnreport" />

报告日期
地位
住址
图像
/*在这里,图像名称以链接形式给出,而#openModal是要弹出的id*/

为链接指定一个类,并使用javascript以该类的链接为目标:

/*here image names are given as link and #openModal is id to  popup*/
<a class="no-default-action" href="?source_id=<?php echo $ARRAY[$i]["source_id"] ?>&#openModal" ><?php echo $ARRAY[$i]["source_photo"] ?> </a>
/*此处图像名称以链接形式给出,#openModal是弹出窗口的id*/


加入以下Javascript代码:

<script>
 var targetLinks = document.querySelectorAll(".no-default-action");
 for(var x in targetLinks)
 {
    targetLinks[x].attachEventListener("click", function(e)
    {
       if(typeof e.preventDefault !== 'undefined'){
        e.preventDefault();
       }
       else{
        e.returnValue = false;
       }

    }, false);
 }
</script>

var targetLinks=document.querySelectorAll(“无默认操作”);
for(targetLink中的变量x)
{
targetLinks[x]。附件“单击”,函数(e)
{
如果(e.preventDefault的类型!==“未定义”){
e、 预防默认值();
}
否则{
e、 returnValue=false;
}
},假);
}

实际上发生的情况是,如果根据日期在数据库中找不到数据,它会显示消息“未找到记录”。因此,当我按下图像链接时,它会刷新到今天的日期(我不知道今天的日期有什么数据),并显示消息“未找到”。我希望它保持原样..因此请帮助显示包含要单击的链接的行..然后尝试这样做:
/*此处图像名称作为链接提供,#openModal是弹出的id*/
注意我使用单引号的位置。让我知道它是否工作删除
onclick=returnfalse
并使用我之前提供的答案和我刚才使用的单引号进行尝试
<div id="openModal" class="modalDialog">
    <div>
    <a class="no-default-action closeno" href="#" onclick="window.close();opener.window.focus()">X</a>

    <div id="makeMeScrollable">
<script>
 var targetLinks = document.querySelectorAll(".no-default-action");
 for(var x in targetLinks)
 {
    targetLinks[x].attachEventListener("click", function(e)
    {
       if(typeof e.preventDefault !== 'undefined'){
        e.preventDefault();
       }
       else{
        e.returnValue = false;
       }

    }, false);
 }
</script>