xtjh

<div onkeydown="javascript:if(event.keyCode==13) search()">

<br >

ISBN<span style="color:red">*</span>:<input name="Text1" type="text" id="searchbox" value="-" >
书名<span style="color:red">*</span>:<input name="Text1" type="text" id="searchbox2" value="">
年:<select name="Select1" id="Select1">
<option></option>
<option></option>
<option></option>
<option></option>
<option>-------</option>
<option></option>
<option></option>
<option></option>
</select>
季:<select name="Select2" id="Select2" style="width: 96px">
<option>春季</option>
<option>秋季</option> </select>
<input name="button1" type="submit" value="提交" id="searchbtn" onclick="search()"> <script type="text/jscript">
//js获取地址栏参数
function getQueryString(name)
{
var reg=new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
var r=window.location.search.substr().match(reg);
if(r!=null)
return unescape(r[]);return null;
}
// 调用方法
//alert(GetQueryString("参数名1"));
//alert(GetQueryString("参数名2"));
//alert(GetQueryString("参数名3")); //查找函数
function search()
{
//alert("ok");
var k=document.getElementById("searchbox").value;
k=escape(k);
if(k==null)
document.getElementById("serchbox").value="-"; var k2=document.getElementById("searchbox2").value; if(typeof(k2)=="undefined" || k2==null || k2.length<) //string 类型 内容为空
{
alert("请输入书名!");
document.getElementById("searchbox2").focus();
return;
}
k2=escape(k2); //if(typeOf(k2)=="undefined")
//document.getElementById("searchbox2").value="图"; var drop = document.getElementById("Select1");
var k3=drop.options[drop.selectedIndex].value;
//获取select的值
k3=escape(k3); var drop2 = document.getElementById("Select2");
var k4=drop2.options[drop2.selectedIndex].value;
//获取select的值
k4=escape(k4); window.location.href="http://point/jcfs/SitePages/xtjh.aspx?k="+k+"&k2="+k2+"&k3="+k3+"&k4="+k4; }
//传递参数刷新界面后保留之前输入的控件框中的内容 首次加载时 k k2均为空
//escape 对字符串进行编码 unescape 对字符串进行解码
document.getElementById("searchbox").value=unescape(getQueryString("k"));
document.getElementById("searchbox2").value=unescape(getQueryString("k2"));
//if(k2=="_") document.getElementById("searchbox2").value="";
var drop = document.getElementById("Select1");
for(i=;i<drop.length;i++)
{//给select赋值
if(unescape(getQueryString("k3"))==drop.options[i].value)
{
drop.options[i].selected=true
}
}
var drop2 = document.getElementById("Select2");
for(i=;i<drop2.length;i++)
{//给select赋值
if(unescape(getQueryString("k4"))==drop2.options[i].value)
{
drop2.options[i].selected=true
}
}//end </script>
<br >
</div>
上一篇:移动端布局的思考和rem的设置


下一篇:第 31 章 项目实战-PC 端固定布局[5]