Possible Duplicate:
Javascript: is using ‘var’ to declare variables optional?
how come in this code example below when i put var before the variables it does not work, however if i remove the var it works? i thought you had to use var when you were creating new variables.
function myfunction () {
    if (document.getElementById('ramyes').checked) {
      var itischecked = "yes"
    } else if (document.getElementById('ramno').checked) {
      var itischecked = "no"
    }
}   
function display () {
  myfunction()
  if (itischecked == "yes") {
    alert ("it sure is");
  } else if (itischecked == "no") {
    alert ("it is not");
  }
}