-
js.js
function check(id){
//alert(id);
for(i=1;i<=3;i++){
document.getElementById("table"+i).style.display="none";
document.getElementById("span"+i).className="";
}
document.getElementById("table"+id).style.display="";
document.getElementById("span"+id).className="span";
}css.css
table{
color:#FF0000;
}
.span{
background-color:#FF0000;
}js.html
<html>
<head>
<title>js smarty</title>
</head>
<link rel="stylesheet" type="text/css" href="/smarty/css/style.css">
<script language=javascript src="/smarty/js/js.js"></script>
<A href="#" onclick="check(1)"><span id="span1" class="span"><{$content}>一</span></a>
<A href="#" onclick="check(2)"><span id="span2"><{$content}>二</span></a>
<A href="#" onclick="check(3)"><span id="span3"><{$content}>三</span></a>
<table border=1 style="display:''" id="table1">
<{section name=loop loop=$log}>
<tr>
<td height=24><a href="/logshow.php?id=<{$log[loop].logid}>&classid=<{$log[loop].logclassid}>" target="_blank"><{$log[loop].title}></a></td>
</tr>
<{/section}>
</table>
<table border=1 style="display:none" id="table2">
<{section name=loop loop=$log2}>
<tr>
<td height=24><a href="/logshow.php?id=<{$log2[loop].logid}>&classid=<{$log2[loop].logclassid}>" target="_blank"><{$log2[loop].title}></a></td>
</tr>
<{/section}>
</table>
<table border=1 style="display:none" id="table3">
<{section name=loop loop=$log3}>
<tr>
<td height=24><a href="/logshow.php?id=<{$log3[loop].logid}>&classid=<{$log3[loop].logclassid}>" target="_blank"><{$log3[loop].title}></a></td>
</tr>
<{/section}>
</table>
</html>js.php
<?php
include("conn.php");
require("libs/smarty.class.php");
$smarty = new Smarty();
$smarty->template_dir = 'templates/'
$smarty->compile_dir = 'templates_c/'
$smarty->config_dir = 'configs/'
$smarty->cache_dir = 'cache/'
$smarty->caching = false;
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$sql="select id,logclassid,title from siyuroom_log order by datetime desc limit 0,5 ";
mysql_query("set names gb2312");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$array[]= array("logid"=>$row["id"],"logclassid"=>$row["logclassid"],"title"=>$row["title"]);
}$sql="select id,logclassid,title from siyuroom_log order by datetime asc limit 0,5 ";
mysql_query("set names gb2312");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$array2[]= array("logid"=>$row["id"],"logclassid"=>$row["logclassid"],"title"=>$row["title"]);
}$sql="select id,logclassid,title from siyuroom_log order by hit desc limit 0,5 ";
mysql_query("set names gb2312");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$array3[]= array("logid"=>$row["id"],"logclassid"=>$row["logclassid"],"title"=>$row["title"]);
}
$smarty->assign("content", "内容");
$smarty->assign("log", $array);
$smarty->assign("log2", $array2);
$smarty->assign("log3", $array3);$smarty->display("js.html");
?>