如何从另一个PHP页面引用PHP页面中的DIV标记



我有两个.php页面,我想知道如何在打印中引用php页面的标记("location.href='eod.php'");第二页。如果我尝试上面的代码,它会把我带到page1.php的主页,但它需要显示page1.php。请建议我。

例如:

page1.php
page2.php

在page1.php中,我有几个属性。现在我想知道如何从page2.php.中引用page1.php页面的特定<div>元素

这是我的示例代码。

Page1.php的div标签:

<div  id="#incidentform2">
<hi>Incident Final Details</h1>
<!-- other markup -->               
</div>

page2.php中的代码:

<?php
include("include/adminclude.php");
if(isset($_POST['submit']))
{
$emailid=$_POST['emailid'];
$incidentno=$_POST['incidentno'];
$startdate=$_POST['startdate'];
//$type=$_POST['type'];
//$priority=$_POST['priority'];
$sa="insert into eod_master(emailid,incidentno,startdt)
VALUES('$emailid','$incidentno','$startdate')";
$aq=mysql_query($sa);
if($aq)
{
print("<script language='javascript'>location.href = 'eod.php'</script>");
}
else
{
print("<script language='javascript'>location.href = 'warning.php'</script>");
}
}
?>

现在我将转到page1.php的主页。但我想知道如何在print("<script language='javascript'>location.href = 'eod.php'</script>");中引用php页面的特定<div>

如果我的问题不清楚,请告诉我。

也许使用了锚?

<script language='javascript'>location.href = 'eod.php#incidentform2'</script>

在您的示例中,我注意到一个错误,您不需要id属性中的锚点:

<div  id="incidentform2">
<h1>Incident Final Details</h1>
...........
..................               
</div>

最新更新