zoukankan      html  css  js  c++  java
  • js搜索

    function check()
    {
    var txtseach=document.getElementById("txtseach");
    var big=window.document.getElementById("bigclass").value;

    var name=encodeURI(txtseach.value);
    if(txtseach.value.length<=0)
    {
    alert('请输入关键字搜索');
    }
    else if(txtseach.value=='输入关键字……')
    {
    alert('请输入关键字搜索');
    }
    else{
    if(big==1)
    {
    location.href="product.aspx?name="+name+"";
    }
    else if(big==2)
    {
    location.href="news.aspx?name="+name+"";
    }


    else{
    alert('请选择类别!');
    }
    }}

    function clearDefaultText (el,message)
    {
    var obj = el;
    if(typeof(el) == "string")
    obj = document.getElementById(id);
    if(obj.value == message)
    {
    obj.value = "";
    }
    obj.onblur = function()
    {
    if(obj.value == "")
    {
       obj.value = message;
    }
    }
    }

    <div class="search"><input name="" type="button" value=" " class="searbu" onclick="return check();"/> <input id="txtseach" name="" type="text" class="searin" value="输入关键字……" onclick="clearDefaultText(this,'输入关键字……')"/><select class="searse"  id="bigclass"><option value="0">选择类别</option><option value="1">产品</option><option value="2">新闻</option></select><span>站内搜索:</span></div>

  • 相关阅读:
    照片墙效果一多实例演示【已封装】
    把javascript event事件封装了下,兼容大多数浏览器
    catch error
    call tcl from c
    scrollbar
    sharedlibextension
    treectrl
    get file name part
    namespace eval
    glob
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2036954.html
Copyright © 2011-2022 走看看