【发布时间】:2014-12-28 04:14:18
【问题描述】:
我正在尝试制作一个可用作闪存卡的网络应用程序,但我需要能够将用户键入的内容输入教科书并将其添加到页面中。这是我找到的,但我希望嵌入文本。
<!DOCTYPE html>
<html lang = "en-US">
<head>
<meta charset = "UTF-8">
<title>textBoxes.html</title>
<script type = "text/javascript">
// from textBoxes.html
function sayHi(){
var txtName = document.getElementById("txtName");
var txtOutput = document.getElementById("txtOutput");
var name = txtName.value;
txtOutput.value = "Hi there, " + name + "!"
} // end sayHi
</script>
<link rel = "stylesheet"
type = "text/css"
href = "textBoxes.css" />
</head>
<body>
<h1>Text Box Input and Output</h1>
<form action = "">
<fieldset>
<label>Type your name: </label>
<input type = "text"
id = "txtName" />
<input type = "button"
value = "click me"
onclick = "sayHi()"/>
<input type = "text"
id = "txtOutput" />
</fieldset>
</form>
</body>
</html>
【问题讨论】:
-
如果你想保存这些结果,最好的办法是把文本发布到一个页面,用 PHP 处理请求并将其保存到 MySQL 数据库中。
标签: javascript html input output