SHOW:
|
|
- or go back to the newest paste.
1 | <!DOCTYPE html> | |
2 | <html> | |
3 | <head> | |
4 | <title></title> | |
5 | <script type="text/javascript"> | |
6 | function substitute() { | |
7 | ||
8 | - | var value = document.getElementById('myTextBox').value; |
8 | + | var value = document.getElementById(myTextBox).value |
9 | ||
10 | if (value.length === 0) { | |
11 | ||
12 | alert("Please enter a real value in the text box"); | |
13 | ||
14 | return; | |
15 | ||
16 | } | |
17 | ||
18 | var title = document.getElementById('title'); | |
19 | title.innerHTML = value; | |
20 | ||
21 | } | |
22 | ||
23 | ||
24 | </script> | |
25 | </head> | |
26 | <body> | |
27 | <h1 id="title">JavaScript Example</h1> | |
28 | <p> | |
29 | <input type="text" id="myTextBox" /> | |
30 | <input type="submit" value="Click me" onclick="substitute()" /> | |
31 | ||
32 | </p> | |
33 | </body> | |
34 | </html> |