Difference between revisions of "Introduction to JavaScript Fall 2011 Class 2"
esse quam videri
Line 22: | Line 22: | ||
var result; | var result; | ||
− | + | <div id="content"> | |
− | + | <form> | |
− | + | <input id="password" type="password"/> | |
− | + | <input id="checkIt" type="submit" /> | |
− | + | </form> | |
− | + | <h1 id="result"> | |
− | + | ||
− | / | + | </h1> |
− | + | ||
− | + | </div> | |
− | |||
− | |||
document.getElementById('checkIt').onclick = function(){ | document.getElementById('checkIt').onclick = function(){ |
Revision as of 04:19, 13 September 2011
Back to Introduction to JavaScript Fall 2011
Contents
Lecture
Setting up your environment
Where to put script
Using the console
variable types
(why to use var)
- string
( \ escape characters )
- number
- bool
- more later
Conditional Statements
var password = "hidden"; var result;
<form> <input id="password" type="password"/> <input id="checkIt" type="submit" /> </form>
document.getElementById('checkIt').onclick = function(){ if(document.getElementById('password').value === password){ result = "access granted"; } else { result = "DENIED!"; } document.getElementById('result').appendChild(document.createTextNode(result)); //document.getElementById('result').firstChild.nodeValue = result; return false; }