zoukankan      html  css  js  c++  java
  • 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';

    ?>

    页面效果为:

  • 相关阅读:
    【leetcode】1020. Partition Array Into Three Parts With Equal Sum
    【leetcode】572. Subtree of Another Tree
    【leetcode】123. Best Time to Buy and Sell Stock III
    【leetcode】309. Best Time to Buy and Sell Stock with Cooldown
    【leetcode】714. Best Time to Buy and Sell Stock with Transaction Fee
    【leetcode】467. Unique Substrings in Wraparound String
    【leetcode】823. Binary Trees With Factors
    【leetcode】143. Reorder List
    【leetcode】1014. Capacity To Ship Packages Within D Days
    【leetcode】1013. Pairs of Songs With Total Durations Divisible by 60
  • 原文地址:https://www.cnblogs.com/siichen/p/3668989.html
Copyright © 2011-2022 走看看