简体   繁体   English

HTMl文字区域

[英]HTMl text area

If we type something in the text area and press submit button, the values should be displayed on the same page under that. 如果我们在文本区域中输入内容,然后按提交按钮,则这些值应显示在该页面的同一页上。 How to do that? 怎么做?

And make stay permanently on the page 并永久停留在页面上

You need javascript. 您需要JavaScript。

<form onsubmit="document.getElementById('output').innerHTML = document.getElementById('tarea1').value;return false">
<textarea id="tarea1"></textarea>
<input type="submit" />
</form>
<div id="output"></div>

You need some server side code, asp.net or PHP 您需要一些服务器端代码,asp.net或PHP

Test for Post/Get parameters Echo text in response 测试发布/获取参数回显文本

If you need to learn about forms and server side basics w3schools.com is the best place to start 如果您需要了解表单和服务器端基础知识,则w3schools.com是最佳起点

In order to store something permanently, you need to have a server running your webpage. 为了永久存储某些内容,您需要让服务器运行您的网页。 You can't just create an HTML file that can get changed on the fly and have those changes become permanent. 您不能只创建可以随时更改并永久保留这些更改的HTML文件。 You'll need to learn a server language (PHP for example) and have a server (like Apache) that can display your page. 您需要学习服务器语言(例如PHP),并拥有可以显示页面的服务器(例如Apache)。

Is this what you're intending? 这是您要的吗? to make an actual site, not just a webpage? 制作一个实际的网站,而不仅仅是一个网页?

Add a piece of JavaScript and attach it to onClick of the submit button. 添加一段JavaScript,并将其附加到“提交”按钮的onClick上。 In the JavaScript, copy the value of the text area into the new place (assign the text to innerHTML ) and also call submit() on the form. 在JavaScript中,将文本区域的值复制到新位置(将文本分配给innerHTML ),然后在表单上调用submit()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM