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>

posted @ 2011-05-04 21:01  放哨De老鼠  阅读(507)  评论(0编辑  收藏  举报