<form name=form1>
<table width=700><tr align=center>
<td><textarea name=taleft cols=40 rows=8>
1. hello
2. how are you
3. fine,thanks
4. bye
</textarea></td>
<td>Line:<br><input type=text size=3 name=text1><br><br><input type=button value=" → " onclick=add()></td>
<td><textarea name=taright cols=40 rows=8></textarea></td>
</tr></table>
<script language=javascript>
  function add(){
    var lines=0,pre=0;
    var wd=form1.taleft.value;
for(var ii=0;ii<wd.length;ii++){
  if(wd.charCodeAt(ii)==10){
    lines++;
if(lines==form1.text1.value){
  form1.taright.value+=wd.substring(pre,ii);
}
pre=ii+1;
  }
}
    if(form1.text1.value>lines){
  alert("  最多 "+lines+" 行  ");
}
  }
</script>

解决方案 »

  1.   

    文本域?我有一个用Select做的例子,不知你是否感兴趣<html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    .link {  font-family: "Webdings"; font-size: 9pt; line-height: 20pt;text-decoration: none;cursor:hand}
    -->
    </style>
    </head>
    <script language="javascript">
    <!--
    function do_select() {
        if (document.form1.select1.options.length > 0) {
            var j=0;
            for(var i=0;i<document.form1.select1.options.length;i++) {
                if(document.form1.select1.options(i).selected) {
                    j=j+1;
                }
            }
        }
        if (j > 0) {
            form1.select2.options[document.form1.select2.options.length]=new Option(document.form1.select1.options[document.form1.select1.selectedIndex].value,document.form1.select1.options[document.form1.select1.selectedIndex].text)
            document.form1.select1.options[document.form1.select1.selectedIndex]=null
        }
    }function do_select2() {
        if (document.form1.select2.options.length > 0) {
            var j=0
            for(var i=0;i<document.form1.select2.options.length;i++) {
                if(document.form1.select2.options(i).selected) {
                    j=j+1
                }
            }
        }
        if (j > 0) {
            document.form1.select1.options[document.form1.select1.options.length] = new Option(document.form1.select2.options[document.form1.select2.selectedIndex].value,document.form1.select2.options[document.form1.select2.selectedIndex].text);
            document.form1.select2.options[document.form1.select2.selectedIndex] =null
        }
    }function do_select3() {
        if (document.form1.select1.options.length > 0) {
            var n=document.form1.select1.options.length;
            for (var i=0;i<n;i++) {
                document.form1.select2.options[document.form1.select2.options.length]=new Option(document.form1.select1.options[0].value,document.form1.select1.options[0].text);
                document.form1.select1.options[0]=null;
            }
        }
    }function do_select4() {
        if (document.form1.select2.options.length > 0) {
            var n=document.form1.select2.options.length;
            for (var i=0;i<n;i++) {
                document.form1.select1.options[document.form1.select1.options.length]=new Option(document.form1.select2.options[0].value,document.form1.select2.options[0].text);
                document.form1.select2.options[0]=null;
            }
        }
    }
    //-->
    </script>
    <body bgcolor="#FFFFFF">
    <p class="link">&nbsp; </p>
    <form name="form1">
    <table width="300" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="126"> 
          <div align="right">
              <select name="select1" size="7" style="WIDTH: 70px" onDblClick="do_select()">
                <option value="11111111">11111111</option>
              <option value="22222222">22222222</option>
              <option value="33333333">33333333</option>
              <option value="44444444">44444444</option>
              <option value="55555555">55555555</option>
              <option value="66666666">66666666</option>
              <option value="77777777">77777777</option>
            </select>
          </div>
        </td>
        <td width="30">
            <div align="center">
                <label onClick="do_select()"><font class="link">4</font></label>
                <br>
                  <label onClick="do_select3()"><u class="link">8</u></label>
            <br>
                <label onClick="do_select4()"><u class="link">7</u></label>
                <br>
                  <label onClick="do_select2()"><u class="link">3</u></label>
            </div>
          </td>
        <td width="144"> 
            <select name="select2" size="7" style="WIDTH: 70px" onDblClick="do_select2()">
            </select>
        </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    多谢以上两位,两位的方法都可以实现我的功能,不过balloy的方法更好些,可惜只有40分,这样吧busibird给10,balloy30。
    thank you!