<head>
<script>
function setParams() {
var year = "2011";
}
function showYear() {
alert("The year is " + year);
}
</script>
</head>
<body>
<input type="submit" onclick="setParams();" value="Set" />
<input type="submit" onclick="showYear();" value="Year" />
</body>
So why does year not enter the dom for alert to read?
means the scope of year is local to the function it is declared in
declare it outside the functions. Or remove the var keyword, which also makes it global.