<body>
----------------------------------------------------------------------------------------------------------
<script language="javascript">
//实现左右select诓的左右对换
  function goleft(){
     var myleft = document.getElementById("left");
     var myright = document.getElementById("right");
  var child1= myright.options[myright.options.selectedIndex]; 
  myright.removeChild(child1); 
  myleft.appendChild(child1); 
  }
   function goright(){
     var myleft = document.getElementById("left");
     var myright = document.getElementById("right");
  var child = myleft.options[myleft.options.selectedIndex]; 
  myleft.removeChild(myleft.options[myleft.options.selectedIndex]); 
  myright.appendChild(child); 
  }
  function gorightall(){    
     var myleft = document.getElementById("left");
     var myright = document.getElementById("right");
  var mylen = myleft.options.length;
  var childd;
  for (var i=0; i<mylen;i++){
     childd = myleft.options[0];
     myleft.removeChild(childd);    
        myright.appendChild(childd);       
 }   
  }
  function goleftall(){    
     var myleft = document.getElementById("left");
     var myright = document.getElementById("right");
  var mylen = myright.options.length;
  var childd;
  for (var i=0; i<mylen;i++){
     childd = myright.options[0];
     myright.removeChild(childd);    
        myleft.appendChild(childd);       
 }   
  }
</script>
<select id="left" name="left" size="4">
  <option value="value1">first</option>
  <option value="value2">second</option>
</select>
<input type="button" value=">>" onClick="goright()">
<input type="button" value="<<" onClick="goleft()">
<select id="right" name="right" size="4">
</select>
<input type="button" value=">>>>" onClick="gorightall()">
<input type="button" value="<<<<" onClick="goleftall()">
<br><br>
----------------------------------------------------------------------------------------------------------
  //ajax
     var xmlHttp;
     function createXMLHttpRequest(){
      if(window.ActiveXObject){
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");     
      }else if(window.XMLHttpRequest){
         xmlHttp = new XMLHttpRequest();
      }
   }
   function startRequest(){
      createXMLHttpRequest();
   xmlHttp.onreadystatechange = callback;  
      xmlHttp.open("POST","/LoadDpartmentServlet",true);
      xmlHttp.send();
   }
   function callback(){
      if(xmlHttp.readyState==4){
       if(xmlHttp.status ==200){
       alert("response.."+xmlHttp.responseText);
    }
   }
   }
</script>


----------------------------------------------------------------------------------------------------------
//树形菜单初探
<script language="javascript">
  function toggle(_dt){
    var _dl = _dt.parentNode;
 if(_dl.className=="collapse") _dl.className="expand";
 else _dl.className="collapse";
  }
</script>
<style type="text/css">
  dl dt {cursor:pointer; padding:3px;}
  dl dd {padding:3px;}
  .expand {height:auto;}
  .collapse {height:20px; overflow:hidden}
</style>
<dl>
  <dt onClick="toggle(this)">root</dt>
  <dd><a href="http://blogjava.net/pear">child</a></dd>
  <dd><a href="http://blogjava.net/pear">child2</a></dd>
  <dl>
   <dt onClick="toggle(this)">root2</dt>
   <dd><a href="http://blogjava.net/pear">child3</a></dd>
   <dd><a href="http://blogjava.net/pear">child4</a></dd>
  </dl>
</dl>
<dl>
  <dt onClick="toggle(this)">root2</dt>
  <dd>child3</dd>
  <dd>child4</dd>
</dl>

<br><br>

----------------------------------------------------------------------------------------------------------

<ul>
  <li>text</li>
  <li>text2</li>
  <ul>
    <li>text3</li>
 <li>text4</li>
 <ul>
   <li>textpk</li>
 </ul>
  </ul>
  <li>text5</li>
</ul>
</body>
</html>

----------------------------------------------------------------------------------------------------------
//创建一个节点的基本方式
           var newnode = document.createTextNode("meme");
           var element = document.createElement("option"); 
           element.appendChild(newnode);
           leftt.appendChild(element); 
-------------------------------
           leftt.options[leftt.options.length]=new Option(value,text)
----------------------------------------------------------------------------------------------------------
//实现列表诓中的字符串连接
<script language="javascript">
   function goright(){
     var myleft = document.getElementById("left");
     var myright = document.getElementById("gogo");
     var len = myleft.options.length;
     for(var i=0; i<len; i++){
        alert(myleft.options[i].text);
        myright.value=myright.value+myleft.options[i].text+'#';
     }
   }

</script>
<select id="left" name="left" size="4">
  <option value="fir">first</option>
  <option value="value2">second</option>
</select>
<input type="button" value=">>" onClick="goright();">

<input type="text" id="gogo" name="gogo">




-------------------------------
<html>
<head>
<title>maomao</title>

</head>
<body>
<script language="javascript">
   function goright(){
     var name=new Array();
     var myleft = document.getElementById("left");
     var myright = document.getElementById("gogo");
     var right = document.getElementById("gg");
     var len = myleft.options.length;
     for(var i=0; i<len; i++){
        name.push(myleft.options[i].text);
        myright.value=myright.value+myleft.options[i].text+'#';
     }
      right.value=name;
     alert(right.value);
   }

</script>
<select id="left" name="left" size="4">
  <option value="fir">first</option>
  <option value="value2">second</option>
</select>
<input type="button" value=">>" onClick="goright();">

<input type="text" id="gogo" name="gogo">
<input type="text" id="gg" name="gg">

 


</body>
</html>

posted on 2006-08-30 22:10 pear 阅读(401) 评论(0)  编辑  收藏 所属分类: 技术

只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问