几个JS的实例




< target =_top  href ="javascript:window.external.addFavorite('http://www.webjx.com','网页教学网');" > 加入收藏 </ a >
< a   href ='http://www.webjx.com/htmldata/2005-12-04/1133660241.html#'  onClick ="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.webjx.com');" > 设为首页 </ a >


< script  language ="JavaScript" >
function GetResult(str)
{
/*
*--------------- GetResult(str) -----------------
* GetResult(str) 
* 功能:通过XMLHTTP发送请求,返回结果.
* 参数:str,字符串,发送条件.
* 实例:GetResult(document.all.userid.value);
* author:wanghr100(灰豆宝宝.net)
* update:2004-5-27 19:02
*--------------- GetResult(str) -----------------
*/

var oBao = new ActiveXObject("Microsoft.XMLHTTP");
oBao.open(
"POST","http://192.168.1.199/Server.do?sel="+str,false);
oBao.send();
//服务器端处理返回的是经过escape编码的字符串.
//
通过XMLHTTP返回数据,开始构建Select.
BuildSel(unescape(oBao.responseText),document.all.sel2)
}


function BuildSel(str,sel)
{
/*
*--------------- BuildSel(str,sel) -----------------
* BuildSel(str,sel) 
* 功能:通过str构建Select.
* 参数:str,字符串,由服务端返回的.有特定结构"字符串1,字符串2,字符串3"
* 参数:sel,要构建的Select
* 实例:BuildSel(unescape(oBao.responseText),document.all.sel2)
* author:wanghr100(灰豆宝宝.net)
* update:2004-5-27 19:02
*--------------- BuildSel(str,sel) -----------------
*/

//先清空原来的数据.
sel.options.length=0;
var arrstr = new Array();
arrstr 
= str.split(",");
//开始构建新的Select.
for(var i=0;i<arrstr.length;i++)
{
sel.options[sel.options.length]
=new Option(arrstr[i],arrstr[i])
}

}

</ script >
< select  name ="sel"  onChange ="GetResult(this.value)" >
< option  value ="" > 请选择
< option  value ="19" > 福建省
< option  value ="21" > 湖北省
< option  value ="22" > 辽宁省
< select >
< select  name ="sel2" ></ select >



< script  >  
<!-- 
function onselectchange()
  num
=document.send.class0.options[document.send.class0.selectedIndex].value; 
  
switch(num)
     
case "0"
document.send.class1.options.length
=4
document.send.class1.options[
00].text="A1"
document.send.class1.options[
00].value=0
document.send.class1.options[
01].text="A2"
document.send.class1.options[
01].value=1
document.send.class1.options[
02].text="A3"
document.send.class1.options[
02].value=2
document.send.class1.options[
03].text="A4"
document.send.class1.options[
03].value=3
break
case "1"
document.send.class1.options.length
=6
document.send.class1.options[
00].text="B1"
document.send.class1.options[
00].value=0
document.send.class1.options[
01].text="B2"
document.send.class1.options[
01].value=1
document.send.class1.options[
02].text="B3"
document.send.class1.options[
02].value=2
document.send.class1.options[
03].text="B4"
document.send.class1.options[
03].value=3
document.send.class1.options[
04].text="B5"
document.send.class1.options[
04].value=4
document.send.class1.options[
05].text="B6";

break;

  }
 
}
 
//--> 
</ script >

 

< table  width ="400"  border ="1"  cellspacing ="0"  cellpadding ="0"  align ="center"  bordercolordark ="#9cc384"  bordercolorlight ="#FFFFFF" >  
  
< tr  bgcolor ="#E6F0DD"  align ="center" >   
    
< td >  
 
      
< form  method ="post"  action ="a_list.asp"  name ="send"  target ="_blank" >  
        
< table  width ="62%"  border ="0"  cellspacing ="2"  cellpadding ="2" >  
          
< tr >   
            
< td  width ="44%"  align ="right" > 类别: </ td >  
            
< td  width ="56%" >   
              
< table  width ="95%"  border ="0"  cellspacing ="0"  cellpadding ="0" >  
                
< tr >   
                  
< td >   
                    
< select  name ="class0"  onChange ="onselectchange()" >  
                      
< option  value ="2" > ** 选择一级类别 ** </ option >  
                      
< option  value ="0" > A </ option >  
                      
< option  value ="1" > B </ option >  
                       
                    
</ select >  
                  
</ td >  
                
</ tr >  
                
< tr >   
                  
< td >   </ td >  
                
</ tr >  
                
< tr >   
                  
< td >   
                    
< select  name ="class1" >  
                      
< option  value ="1" > ** 选择二级类别 ** </ option >  
                    
</ select >  
                  
</ td >  
                
</ tr >  
              
</ table >  
            
</ td >  
          
</ tr >  
        
</ table >  
      
</ form >  
      
 
      
 
    
</ td >  
  
</ tr >  
   
</ table >
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值