如何将四个文本框值的内容复制到HTML中的一个文本区域? [英] How to copy Content of four textbox values to a one textarea in HTML?

查看:94
本文介绍了如何将四个文本框值的内容复制到HTML中的一个文本区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单包含四个 文本框和一个 textarea 字段。表格就像请求表格。我希望将四个文本框的内容复制到 textarea 。为此,我写了 onkeyup 事件,同时将其值复制到 textarea ,但我希望将所有四个文本框值复制到文本区域。这是我为onkeyup事件编写的代码



 <  < span class =code-leadattribute> input     type   =  text      id   =  C.name    name   =  C.name   必需       önkeyup  =  document.getElementById('message')。value = this.value >  





但是此事件只复制一个文本框值。我希望所有文本框值都被复制到textarea。

我应该怎么做才能将所有文本框的值复制到textarea?

解决方案

< blockquote>我这里有3个文本框。第三个是通过其他两个文本框更新。同样聪明的你可以根据你的要求进行整合



HTML



 Fisrt名称: -  <  输入   < span class =code-attribute> type   =  text    id   = 首先   >  <   / input  >  
姓氏: - < 输入 type = text id = last < span class =code-attribute> onkeyUp = copyText() > < / input >
全名: - < input 类型 = text id = full > < / input >





JS

  function  copyText(){
first = document .getElementById( first);
last = document .getElementById( last );
full = document .getElementById( full );
full.value = first.value + ' ' + last.value;
}


I have a form which contains four textboxes and one textarea field. the form something like request form. I want the content of four textboxes get copied to textarea. For this i have write onkeyup event which simultaneously copy its value to textarea but i want all the four textbox values get copied to the text area. This is the code i write for onkeyup event

<input type="text"  id="C.name" name="C.name" required   önkeyup="document.getElementById('message').value=this.value">



But with this event only one textbox value get copied. I want all the textbox value get copied to textarea.
What should i do so that the value of all textbox get copied to textarea?

解决方案

I have 3 text boxes here. and 3rd one is updating by other two text boxes. Like wise you can intergrate it to your requirement

HTML

Fisrt name:-<input type="text" id="first" ></input>
Last Name:-<input type="text" id="last" onkeyUp="copyText()" ></input>
Full Name:-<input type="text" id="full" ></input>



JS

function copyText() {
first = document.getElementById("first");
last = document.getElementById("last");
full = document.getElementById("full");
full.value = first.value + ' ' + last.value;
}


这篇关于如何将四个文本框值的内容复制到HTML中的一个文本区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆