PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

站内搜索的实现 [复制链接]

1#
能不能把站内搜索变成这种下拉的格式,而且现在的这种格式我也要,只是在不同页面我用不同的格式,但要搜出来的效果都一样,所以请哪位高手给一个下拉式的搜索代码。小弟3Q了。
分享 转发
TOP
2#

可以把include下的searchbox.aspx复制一个新文件,改名为searchbox._1.aspx

把里面radiobutton改为select的下拉就可以了,我自己没有改过,但是这个方法肯定行

调用时候<script src=/include/searchbox._1.aspx></script>
TOP
3#


哦~~~~
xiyou,xiyou我爱你,就像老鼠爱大米....
TOP
4#

里面的我改不了呀。还是原来那样
TOP
5#

回复 2# xiyou 的帖子

好办法
TOP
6#

<% @ Page  language="c#"  Inherits="PageAdmin.searchbox" %>
<asplaceHolder id="P1" runat="server"  visible="false">
document.write("<ul>");
document.write("<li class='searchbox_item'><input  id='searchkey_<%=Id%>' type='text' class='searchbox_textbox'>");
document.write("<a href='javascript:searchbox_1_<%=Id%>()'><img alt='' align='absMiddle' border='0' src='/images/public/search.gif'></a></li>");
document.write("</ul>");
</asplaceHolder>

<asplaceHolder id="P2" runat="server"  visible="false">
document.write("<ul>");
document.write("<li class='searchbox_item'><input  id='searchkey_<%=Id%>' type='text' class='searchbox_textbox'>");
document.write("<a href='javascript:searchbox_2_<%=Id%>()'><img alt='' align='absMiddle' border='0' src='/images/public/search.gif'></a></li>");
document.write("</ul>");
</asplaceHolder>

<asplaceHolder id="P3" runat="server"  visible="false">
document.write("<ul>");
document.write("<li class='searchbox_item'><input id='sboxradio1_<%=Id%>' name='sboxradio_<%=Id%>' type='radio'  checked><%=Tags_1%>&nbsp;&nbsp;<input  name='sboxradio_<%=Id%>' id='sboxradio2_<%=Id%>' type='radio' /><%=Tags_2%>&nbsp;&nbsp;</li>");
document.write("<li class='searchbox_item'><input   type='text'  id='searchkey_<%=Id%>' class='searchbox_textbox' >");
document.write("<a  href='javascript:searchbox_3_<%=Id%>()'><img alt='' align='absMiddle' border='0' src='<%=Tags_3%>'></a></li>");
document.write("</ul>");
</asplaceHolder>



function searchbox_1_<%=Id%>()
{
  
  var Language="<%=P_Language%>";
  var Js1,Js2;
  if(Language=="en")
   {
      Js1="Please enter your search product name or type keywords!";
      Js2="Keyword must be greater than 2 characters!";
   }
  else
   {
      Js1="请输入要搜索的产品名称或型号关键字!";
      Js2="关键字必须大于2个字符!";
   }

  var Keycode=escape(Trim(document.getElementById("searchkey_<%=Id%>").value));
  var Target="<%=Target%>";
   if(Keycode=="")
    {
     alert(Js1);
      document.getElementById("searchkey_<%=Id%>").focus();
     return;
    }
   else
    {
     if(Keycode.length<2)
      {
       alert(Js2);
       document.getElementById("searchkey_<%=Id%>").focus();
       return;
      }
     else
     {
        if(Target==1)
          {
            window.open("/include/search.aspx?keycode="+Keycode+"&type=1&language="+Language, "_target");
          }
        else
          {
            location.href="/include/search.aspx?keycode="+Keycode+"&type=1&language="+Language;
          }
     }
    }
}

function searchbox_2_<%=Id%>()
{

  var Language="<%=P_Language%>";
  var Js1,Js2;
  if(Language=="en")
   {
      Js1="Please enter your search to the title of the article or profile keyword!";
      Js2="Keyword must be greater than 2 characters!";
   }
  else
   {
      Js1="请输入要搜索的文章标题或简介关键字!";
      Js2="关键字必须大于2个字符!";
   }


  var Keycode=escape(Trim(document.getElementById("searchkey_<%=Id%>").value));
  var Target="<%=Target%>";
   if(Keycode=="")
    {
     alert(Js1);
      document.getElementById("searchkey_<%=Id%>").focus();
     return;
    }
   else
    {
     if(Keycode.length<2)
      {
     alert(Js2);
      document.getElementById("searchkey_<%=Id%>").focus();
     return;
      }
     else
     {
       if(Target==1)
          {
            window.open("/include/search.aspx?keycode="+Keycode+"&type=2&language="+Language, "_target");
          }
        else
          {
            location.href="/include/search.aspx?keycode="+Keycode+"&type=2&language="+Language;
          }
     }
    }
}

function searchbox_3_<%=Id%>()
{
   var Obj=document.getElementById("sboxradio1_<%=Id%>");
   if(Obj.checked)
    {
     searchbox_1_<%=Id%>();
    }
   else
    {
     searchbox_2_<%=Id%>();
    }
}
function Trim(str)
{
  var Astr=str.split('');
  var str1="";
  for(i=0;i<Astr.length;i++)
   {
    str1+=Astr.replace(" ","");
   }
  return str1;
}
TOP
7#

不知道改哪一点,"把里面radiobutton改为select的下拉就可以了",找不到地方
TOP
发新话题 回复该主题