textbox onblur get value do calculation
In a different trial, I have succeeded to capture user data with a prompt and then run two conditional if statements...
...but, prompts seem old and dumb to me so I am trying to capture user data with a textbox instead of a prompt and I'm running into failure. Here is what I am trying to do:
1. user puts data into textbox
2. I get value of textbox
3. I do a calculation with that value
4. I write the answer
This is what I've got:
Enter your birth year: <input type="text" id="birthyear" onblur="age ()">
var birthyear = document.getElementById('birthyear').value;
var today = 2012;
var age = today - birthyear;
Please don't be too harsh on me ;)
If you have a good tutorial to refer me to that'd be awesome too.