我试图在另一个php文件中更改div元素的style.display属性,当我点击链接(在index.php中)时,由ajax调用。这可能吗?
index.php代码:
<div id="list">
<h2 id="cat_price" style="color:#f5c658">Price Category</h2>
<ul class="ul1">
<?php
$sql="select * from category";
$execute=mysql_query($sql);
while($row=mysql_fetch_assoc($execute)){ ?>
<li><a href="#" onclick="javascript:show(<?php echo $row['id']; ?>)"><?php echo $row['category'] ; ?></a></li>
<?php } ?>
</ul>
</div>
<div id="waxing">
</div>
我要执行脚本代码的另一个php文件代码:
<?php
include 'admin/connect.php' ;
$id=$_REQUEST['did'];
echo "<script>alert('$id');</script>" ;
if(isset($_REQUEST['did']))
{
$id=$_REQUEST['did'];
$sql="select * from midcat where cid=$id";
$execute=mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($execute)>0){
$display="<h2 style='color:#f5c658'>Price Category Waxing</h2>";
$display.="<ul class='ul1'>";
echo "<script> document.getElementById('list').style.display='none';</script>";
while($row=mysql_fetch_assoc($execute)){
$display.="<li> <a href='#'>$row[midcat]</a></li>";
}
$display.="<li><a href='#' onclick='javascript:back()'>Back</a></li>" ;
$display.="</ul>";
echo $display;
}
}
?>