<textarea name=\"intro\" cols=22 rows=1 id='aa"+i+"'> </textarea><input name="title" type="text" size="37">
我需要在这个文本框填写的内容,自动复制到textarea里面。也就是说,textarea的值和这个input是一样的。
但是,textarea数量不限。不是一个,是一串。麻烦高手。

解决方案 »

  1.   

    一串是什么意思?一个文本框的内容怎么同步到一串textarea中去?
      

  2.   

    <script type="text/javascript">
    function changetextarea()
    {
        //get the content of the input and set the textare.value as the content...
    }
    </script>
    <input type="text" name="title" size="37" onchange="changetextarea()"/>
      

  3.   

    谢谢。我没成功。
    不会做这种类型的textarea,因为不是一个。<textarea name=\"intro\" cols=22 rows=1 id='aa"+i+"'> </textarea>比如会如下这样:
    <textarea name=\"intro\" cols=22 rows=1 id=aa1> </textarea>
    <textarea name=\"intro\" cols=22 rows=1 id=aa2> </textarea>
    <textarea name=\"intro\" cols=22 rows=1 id=aa3> </textarea>
      

  4.   

    <textarea name=\"intro\" cols=22 rows=1 id='aa"+i+"'> </textarea><input name="testbutton1"  type="text" onpropertychange="document.getElementById('aa"+i+"').value=this.value"> 是说未结束……
      

  5.   


    var copyString = function(textID, areaID){
        this.text = document.getElementById(textID);
        this.areaList = document.getElementById(areaID).getElementsByTagName('textarea');
        this.init();
    }copyString.prototype ={
        init: function(){
            var _self = this;
            this.text.onkeyup = function(){_self.copyValue()};
            this.text.onpaste = function(){_self.copyValue()};
        },
        copyValue: function(){
            var _value = this.text.value;
            for(each in this.areaList){
                this.areaList[each].value = _value;
            }
        }
    }
      

  6.   

    我下面这个,单独是正常的:
    <textarea name=\"intro\" cols=22 rows=1 id=aa> </textarea>
    <input name="testbutton1" type="text" onpropertychange="document.getElementById('aa').value=this.value"> 但是,下面这样写就不行了:
    <textarea name=\"intro\" cols=22 rows=1 id='aa"+i+"'> </textarea>
    <input name="testbutton1" type="text" onpropertychange="document.getElementById('aa"+i+"').value=this.value"> 
      

  7.   

    6楼的高手,你的运行没错误,也没效果。<script>
    var copyString = function(aaa, bbb){
        this.text = document.getElementById(aaa);
        this.areaList = document.getElementById(bbb).getElementsByTagName('textarea');
        this.init();
    }copyString.prototype ={
        init: function(){
            var _self = this;
            this.text.onkeyup = function(){_self.copyValue()};
            this.text.onpaste = function(){_self.copyValue()};
        },
        copyValue: function(){
            var _value = this.text.value;
            for(each in this.areaList){
                this.areaList[each].value = _value;
            }
        }
    }
    </script>
    <input name=testbutton1  type=text id=aaa> 
    <textarea name=\"intro\" cols=22 rows=3 id=bbb> </textarea>
      

  8.   

    学习一下onPropertyChange 事件,
      

  9.   


    <script type=text/javascript>
    window.onload = function () {
           document.onkeyup = function () {
                  var obj = document.getElementsByTagName("textarea"),
                  str = document.getElementsByTagName("input")[0].value;
                  for(var i=0,j=obj.length; i<j; i++)obj[i].value = str;   
           }
    }
    </script><textarea name="intro" cols=22 rows=3> </textarea>
    <textarea name="intro" cols=22 rows=3> </textarea>
    <textarea name="intro" cols=22 rows=3> </textarea>
    <textarea name="intro" cols=22 rows=3> </textarea>
    <textarea name="intro" cols=22 rows=3> </textarea>
    <textarea name="intro" cols=22 rows=3> </textarea>
    <input type="text">
      

  10.   

    谢谢10楼。好像快成功了。
    单独测试可以。
    但是由于实际页面上不止一个input。所以运行有点问题。
    能否指定input
    <input name="title" type="text" size="37" >
      

  11.   

    6楼的代码在for each那块好像有问题.我改了一下<input name=testbutton1 type=text id=txt>
    <div id="d">
    <textarea name="intro" cols=22 rows=3 > </textarea>
    <textarea name="intro" cols=22 rows=3 > </textarea>
    <textarea name="intro" cols=22 rows=3 > </textarea>
    <textarea name="intro" cols=22 rows=3 > </textarea>
    </div>
    <script>
    var copyString = function(aaa, bbb){
    this.text = document.getElementById(aaa);
    this.areaList = document.getElementById(bbb).getElementsByTagName('textarea');
    this.init();
    } copyString.prototype = {
    init: function(){
    var _self = this;
    this.text.onkeyup = function(){_self.copyValue()};
    this.text.onpaste = function(){_self.copyValue()};
    },
    copyValue: function(){
    var _value = this.text.value;
    for(var i=0;i<this.areaList.length;i++){
    //alert(i)
    this.areaList[i].value = _value;
    }
    }
    } new copyString("txt","d");
    </script>
      

  12.   

    windzjp的代码,单独测试都是正常的。可是放到程序中就不行了。
    看下面代码,我输入文本框只有一个。我要这个文本框的输入内容自动复制到其他若干textarea中。
    针对我的这个情况,该如何是好。谢谢。<script language="JavaScript">
    var allfilefolder
    var allfilename
    var filearr
    var start = 1
    var end
    var s;
    function selectfiletype()
    {
    var sHTML = ',';
    var oListft = document.all.ft;
    for ( var i = 0 ; i < oListft.length ; i++ )
    {
    var sValue = oListft[i].value.replace("<br>","");
    if (oListft[i].checked)
    {
    sHTML += sValue+"," ;
    }
    }
    document.all.allselectfileeext.value = sHTML;
    }function creatinput()
    {
    var allfilefolder = document.all.pathstr.value
    var allfilename = document.all.fileliststr.value
    var filearr = allfilename.split("|")
    end  = filearr.length+1
    formhtml = " <input name='title' type='text' size='37' id=txt>"
    for (i=start;i<end;i++)
    {
    k = "00000"+i;
    k = k.substr(k.length-4,4)
    formhtml+="("+k+"). <textarea name=\"imageintro\" cols=22 rows=1> </textarea>  <br>" }
    document.all.MyZone.innerHTML=formhtml;
    document.form1.button.focus();
    //s = setInterval("setfile(start)",50);
    }</script>