showing results for - "how to display output in textbox in javascript"
Laura
04 Jan 2020
1<!DOCTYPE html>
2<html lang = "en-US">
3 <head>
4 <meta charset = "UTF-8">
5 <title>textBoxes.html</title>
6 <script type = "text/javascript">
7  // from textBoxes.html
8  function sayHi(){
9  var txtName = document.getElementById("txtName");
10  var txtOutput = document.getElementById("txtOutput");
11  var name = txtName.value;
12  txtOutput.value = "Hi there, " + name + "!"
13  } // end sayHi
14 </script>
15 <link rel = "stylesheet"
16   type = "text/css"
17   href = "textBoxes.css" />
18 </head>
19 <body>
20 <h1>Text Box Input and Output</h1>
21 <form action = ">
22  <fieldset>
23  <label>Type your name: </label>
24  <input type = "text"
25    id = "txtName" />
26  <input type = "button"
27    value = "click me"
28    onclick = "sayHi()"/>
29  <input type = "text"
30    id = "txtOutput" />
31  </fieldset>
32 </form>
33 </body>
34</html>