Tell us what’s happening:
I am getting the null error and I am not sure what I am doing wrong. Is my syntax wrong? Am I not setting the input element properly?
The console is telling me:
your input element should have a type attribute set to text.
Your input element should have a placeholder attribute set to Name.
Your input element should have an id attribute set to ${entryDropdown.value}-${entryNumber}-name.
Your code so far
function addEntry() {
const targetInputContainer = document.querySelector(#${entryDropdown.value} .input-container
);
const entryNumber = targetInputContainer.querySelectorAll(‘input[type=“text”]’).length;
const HTMLString = <label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label> <input type="text" placeholder="Name" id="${entryDropdown.value}-${entryNumber}-name"
}
WARNING
The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.
You will need to take an additional step here so the code you wrote presents in an easy to read format.
Please copy/paste all the editor code showing in the challenge from where you just linked.
function addEntry() {
const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
const HTMLString = `
<label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label>
<input type="text" placeholder="Name" id="${entryDropdown.value}-${entryNumber}-name"
`
}
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 46