我有一个包含各种字段的表单。我有一个按钮' GET REPORT'。按下此按钮,所需的内容显示在表格中。在表格中我有一个名为图像的列,这是一个链接到图像。当我按下链接时,弹出窗口出现image.my问题是,点击弹出窗口时图像出现但页面得到刷新。我希望它保持在同一页面上,即使是流行音乐打开和关闭。
这是我的表,从数据库中提取值
<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" />
这是我的图像名称从数据库中获取并在弹出窗口中显示的方式。
<div id="openModal" class="modalDialog">
<div>
<a href="#" onclick="window.close();opener.window.focus()" class="closeno">X</a>
<div id="makeMeScrollable">
<?php
$id=$_GET['source_id'];
$sql1=mysql_query("SELECT source_photo FROM source_main where source_id ='$id'");
while($result=mysql_fetch_assoc($sql1))
{
$result['image'] = trim($result['source_photo'],'\,');
$temp = explode(',',$result['source_photo'] );
$temp = array_filter($temp);
foreach($temp as $image){
$images[]="images/demo/".trim( str_replace( array('[',']') ,"" ,$image ) );
}
}
foreach($images as $image){
//if(is_file(ROOTDIR.$image))
echo "<img src='{$image}' height='250' width='280' />";
}
?>
</div></div></div>
我该怎么做...请帮助。谢谢提前
答案 0 :(得分:0)
为您的链接提供一个类,并使用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>
和
<div id="openModal" class="modalDialog">
<div>
<a class="no-default-action closeno" href="#" onclick="window.close();opener.window.focus()">X</a>
<div id="makeMeScrollable">
扔进这个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>