I am missing something really obvious here, this is my first attempt at Javascript. I am trying to click radio buttons to fill out some forms, and the code is all pretty straightforward...
Firefox says that streetInput is null. This happens when I click a radiobutton. Streetinput is the id for the form to be filled out.
textContent is supposed to fill out the forms with the given text, but it doesn't. None of it does.
Chrome says script.js:37 Uncaught TypeError: Cannot read property 'addEventListener' of null
var homeOption = document.querySelector(".homeoption");
var workOption = document.querySelector(".workoption");
var streetInput = document.querySelector(".streetinput");
var cityInput = document.querySelector(".cityinput");
var stateInput = document.querySelector(".stateinput");
var zipInput = document.querySelector(".zipinput");
function HomeFillout() {
streetInput.textContent = "1 Main St.";
cityInput.textContent = "Sicilia";
stateInput.textContent = "ME";
zipInput.textContent = "03900";
if (form.checkValidity() === true) {
submitButton.className = "submitbutton show";
}
}
function WorkFillout() {
streetInput.textContent = "15 Columbine Ln.";
cityInput.textContent = "Crab City";
stateInput.textContent = "ME";
zipInput.textContent = "04993";
if (form.checkValidity() === true) {
submitButton.className = "submitbutton show";
}
}
homeOption.addEventListener("click", HomeFillout, false);
workOption.addEventListener("click", WorkFillout, false);