MVC 框架中 实现点击热点浮动框显示详细信息

2鼠标移动到热点上,显示详细信息

<html>

<head>

<scripttype="text/javascript">

functionshowOne(id){

var xhr =window.XMLHttpRequest?new XMLHttpRequest():newActiveXObject("Msxm12.XMLHTTP");

         varurl="index.php?c=user&a=showOne";

         xhr.open("post",url,true);//post方式打开地址栏必须传一个头文件

         //true 参数表示是否异步

         xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

         xhr.send("brand_id="+id);

         xhr.onreadystatechange =callback;

                   function callback(){

                            //alert(xhr.readyState);

                            if(xhr.readyState ==4){

                                     if(xhr.status== 200){//请求发送成功

                                               //eval()如果想要将字9符串转化成对象,需先将对象运行一下,通过'()'

                                               varjson =eval("("+xhr.responseText+")");

                                               varnew_div =document.createElement('div');

                                               new_div.style.backgroundColor= "yellow";

                                               new_div.id="new_div";

                                               new_div.style.position="absolute";

                                               new_div.style.width="250px";

                                               new_div.style.marginLeft="180px";

                                               new_div.innerHTML="详细信息:<br/>网址:"+json.brand_wz+"<br/>简介:"+json.brand_intro;

                                               document.getElementById(id).appendChild(new_div);

                                     }

                            }

                    }

}

functiondelOne(id){

         var new_div=document.getElementById("new_div");

         document.getElementById(id).removeChild(new_div);

}

</script>

</head>

<body>

<tablewidth="250px" align="center">

<caption>地图式图层浮动</caption>

<{foreachfrom=$list item="value"}>

<trbgcolor="#ccc">

         <tdid="<{$value.brand_id}>"οnmοuseοver="showOne(<{$value.brand_id}>)"οnmοuseοut="delOne(<{$value.brand_id}>)"><{$value.brand_id}></td>

         <tdid="<{$value.brand_id}>"οnmοuseοver="showOne(<{$value.brand_id}>)"οnmοuseοut="delOne(<{$value.brand_id}>)"><{$value.brand_name}></td>

</tr>

<{/foreach}>

</table>

</body>

</html>

 

//  命令模型层查询数据   视图层显示

         //实现   地图搜索  弹出图层

         public function showDetailAction(){

                   $user_model=newuserModel('localhost','root','','yanhua');

                   $rows=$user_model->getAll();

                   $this->smarty->assign('list',$rows);

                   $this->smarty->display('showDetail.tpl');

         }

         // 获取传递得值  在模型层查询  并返回

         public function showOneAction(){

                   $brand_id=$_REQUEST['brand_id'];

                   $user_model=newuserModel('localhost','root','','yanhua');

                   $rows=$user_model->getOne($brand_id);

                   echo json_encode($rows);

         }

userController.class.php//控制器代码

//  命令模型层查询数据   视图层显示

         //实现   地图搜索  弹出图层

         publicfunction showDetailAction(){

                   $user_model=newuserModel('localhost','root','','yanhua');

                   $rows=$user_model->getAll();

                   $this->smarty->assign('list',$rows);

                   $this->smarty->display('showDetail.tpl');

         }

         //  获取传递得值  在模型层查询  并返回

         publicfunction showOneAction(){

                   $brand_id=$_REQUEST['brand_id'];

                   $user_model=newuserModel('localhost','root','','yanhua');

                   $rows=$user_model->getOne($brand_id);

                   echojson_encode($rows);

         }

 

 

userModel.class.php //模型层查询数据

public function getAll(){

                   $sql= "select * from brand";

                   $res=mysql_query($sql);

                   $rows=array();

                   while($row=mysql_fetch_assoc($res)){

                            $rows[]=$row;

                   }

                   return$rows;

         }

         publicfunction getOne($brand_id){

                   $sql= "select * from brand where brand_id='".$brand_id."'";

                   $res=mysql_query($sql);

                   $row=mysql_fetch_assoc($res);

                   return$row;

         }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值