js 用js做一个添加记录,要求:页面上有一文本域,一文本框 和保存按钮。在文本框中添加内容,点击保存,此内容显示在文本域中,再在文本框中填写内容,点击保存,此内容也显示在文本域中,前后两条记录分行显示,怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不要用textarea,用divvar d = document.getElementById(divId);d.innerHTML += '第一行' + '<br />';d.innerHTML += '第二行' + '<br />'; 你那样做的话,实现如下:每次点击按钮的时候,分别获取text和textarea里面的内容,将textarea的内容重写,中间添加换行符合就可以了。<html> <head> <script> function updateValue(){ var textValue = document.getElementById("text1").value; alert(textValue); var textareaValue = document.getElementById("contactus").value; alert(textareaValue); document.getElementById("contactus").value=textareaValue+"\n"+textValue;}</script> </head> <body ><form name="form1"><table cellpadding="0" cellspacing="0" border="0" width="100%" > <tr> <td> <input type="text" name="text1" value=""/> <textarea cols="5" rows="5" id="contactus" name="contactus"> </textarea><input type="button" name="button1" onclick="updateValue()"></td></tr> </table> </form></body> </html> 改了一下楼上的 楼上的没考虑完全 会有空格 <html> <head> <script> function updateValue(){ var textValue = document.getElementById("text1").value; var textareaValue = document.getElementById("contactus").value; if(textareaValue!=""){ document.getElementById("contactus").value=textareaValue+"\r"+textValue; }else{ document.getElementById("contactus").value += textValue; }} </script> </head> <body > <form name="form1"> <table cellpadding="0" cellspacing="0" border="0" width="100%" > <tr> <td> <input type="text" name="text1" value=""/> <textarea cols="20" rows="5" id="contactus" name="contactus"></textarea> <input type="button" name="button1" onclick="updateValue()"> </td> </tr> </table> </form> </body> </html> jave web 批量上传 SSH2中的action中需要使用多个业务层,该如何配置? org.git.mm.mysql.Driver.Class not found form中二维数组的属性的赋值问题 textarea内容怎么在页面上格式化显示 jsp中调用servlet问题!(在线等!) weblogic+jbuilder如何配置jspsmartupload word-->java-->PDF 菜鸟首问-让我完成第一个index.jsp! JAVA Web JSP中的问题 当关闭主页面时, 如何销毁保存在ServletContext里的当前用户名 怎么用jsp将图片存放在mysql中呢?
var d = document.getElementById(divId);d.innerHTML += '第一行' + '<br />';
d.innerHTML += '第二行' + '<br />';
每次点击按钮的时候,分别获取text和textarea里面的内容,将textarea的内容重写,中间添加换行符合就可以了。
<html>
<head>
<script>
function updateValue(){
var textValue = document.getElementById("text1").value;
alert(textValue);
var textareaValue = document.getElementById("contactus").value;
alert(textareaValue);
document.getElementById("contactus").value=textareaValue+"\n"+textValue;
}
</script>
</head>
<body >
<form name="form1">
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
<tr>
<td>
<input type="text" name="text1" value=""/>
<textarea cols="5" rows="5" id="contactus" name="contactus">
</textarea><input type="button" name="button1" onclick="updateValue()">
</td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<script>
function updateValue(){
var textValue = document.getElementById("text1").value;
var textareaValue = document.getElementById("contactus").value;
if(textareaValue!=""){
document.getElementById("contactus").value=textareaValue+"\r"+textValue;
}else{
document.getElementById("contactus").value += textValue;
}
}
</script>
</head>
<body >
<form name="form1">
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
<tr>
<td>
<input type="text" name="text1" value=""/>
<textarea cols="20" rows="5" id="contactus" name="contactus"></textarea> <input type="button" name="button1" onclick="updateValue()">
</td>
</tr>
</table>
</form>
</body>
</html>