28,406
社区成员
发帖
与我相关
我的任务
分享
<select id="select4" name="select4">
<option value="">全部省</option>
<option value="北京市">北京市</option>
<option value="上海市">上海市</option>
<option value="天津市">天津市</option>
<option value="重庆市">重庆市</option>
<option value="河北省">河北省</option>
<option value="山西省">山西省</option>
..............
</select>
<script type="text/javascript">
function replaceProvinceVal(strSel){
var currLink=window.location.href;
var strAmpIndex,strInterIndex,maxk,tmpProvince;
strInterIndex=(currLink.indexOf("?")!=-1)?currLink.indexOf("?"):0;
strAmpIndex=(currLink.lastIndexOf("&")!=-1)?currLink.lastIndexOf("&"):0;
maxk=currLink.length;
if(strInterIndex>0 && currLink.lastIndexOf("prov")>0){
if(strAmpIndex>0){
if(currLink.lastIndexOf("prov")-strInterIndex==1){
tmpProvince=currLink.substring(currLink.lastIndexOf("prov")+5,strAmpIndex);
}else if(currLink.lastIndexOf("prov")-strAmpIndex==1){
tmpProvince=currLink.substring(currLink.lastIndexOf("prov")+5,maxk);
}
}else{
tmpProvince=currLink.substring(currLink.lastIndexOf("prov")+5,maxk);
}
currLink=currLink.replace(tmpProvince,escape(strSel.value));
}else if(strAmpIndex==0 && strInterIndex==0){
currLink+="?prov="+escape(strSel.value);
}else{
currLink+="&prov="+escape(strSel.value);
}
window.location.href=currLink;
}
if($('select4')){
$('select4').addEvent('change',function(event){
new Event(event).stop();
replaceProvinceVal(this);
});
}
</script>