• dedecms首页搜索 添加仿百度下拉框


    1:找到uploads/templets/default/head.htm 

    2: 找到 

    <input name="q" type="text"  class="search-keyword" id="aa" value="在这里搜索..." onfocus="if(this.value=='在这里搜索...'){this.value='';}"    onkeydown="document.getElementById('ssxlk').style.display= 'block';"  oninput="_getvalue()"   onblur="if(this.value==''){this.value='在这里搜索...';}" />

    添加  autocomplete="off" 系统input 默认autocomplete on 

    3:在相应位置添加一个div  id="ssxlk"

    4:添加javascript代码:

    <script type="text/javascript" src="ajax.js"></script>

    <script type="text/javascript" >

    function _getvalue()

    {

    var res = "id="+document.getElementById('aa').value;

    //var gvalue =  document.getElementByID().value;

    getajax('ssxxl.php',res,b);

    }

    function b(a)

    {

    if(document.getElementById('aa').value=='')

    {

    document.getElementById('ssxlk').innerHTML='';

    }

    else

    {

    document.getElementById('ssxlk').innerHTML=a;

    }

    //alert(a);

    }

    </script>

     

    5ajax.js页面:

    function getajax(url,j,responsefunction){

    if(url){

    var xhr=ajax();

    xhr.open("POST",url,true);

    xhr.onreadystatechange=function(){

    if(xhr.readyState==4){

    if(xhr.status==200){

    responsefunction(unescape(xhr.responseText));

    }else{

    alert("页面读取失败");

    }

       }

    };

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

    xhr.send(j); //发送请求

    }else{

    alert("未知错误,请查识");

    }

    }

    function ajax(){

    var http_request;

    if(window.XMLHttpRequest){

    http_request=new XMLHttpRequest();

    if(http_request.overrideMimeType){

    http_request.overrideMimeType("text/xml");

    }

    }else if(window.ActiveXObject){

    try{

    http_request=new ActiveXObject("Msxml2.XMLHttp");

    }catch(e){

    try{

    http_request=new ActiveXobject("Microsoft.XMLHttp");

    }catch(e){

    }

    }

    }

    if(!http_request){

    window.alert("创建XMLHttp对象失败!");

    return false;

    }

    return http_request;

    }

    6ssxxl.php页面

    <?php

    mysql_connect('localhost','root','root');

    mysql_select_db('dedecms');

    mysql_query('set names utf8');

    $sql = "select `typename` from `dede_arctype` where `typename` like '%".$_POST['id']."%' limit 0,9;";

    //print_r($sql);

    $result = mysql_query($sql);

    if($row = mysql_fetch_array($result))

    {

    do

    {

    echo $row[0];

    echo "<br />";

    }

    while($row = mysql_fetch_array($result));

    }

    //echo 'aaaaaa';

    ?>

    页面效果为:

    清风明月本无价,近水远山皆有情。
  • 相关阅读:
    MR中简单实现自定义的输入输出格式
    简单实现CombineFileInputFormat
    提高mapreduce性能的七点建议
    MR中使用sequnceFIle输入文件
    Hive中使用LZO
    JVM启动参数详解 (转)
    ubuntu12.04中shell脚本无法使用source的原因及解决方法
    hadoop 错误
    poj 3211 Washing Clothes
    hdu 3535 AreYouBusy
  • 原文地址:https://www.cnblogs.com/onlylove2015/p/4393812.html
Copyright © 2020-2023  润新知