HI i am practicing resume creator app using JavaScript. i wanted to take all user inputs using gelements by id method in a loop.
when i am trying getting error of null regarding value property
without loop:
const fullName = document.getElementById("fullName"); // Getting Text from input
const fullNameT = document.getElementById("fullNameT"); // Writing fullName in template
fullName.innerText = fullNameT;
in that case i have to write multiple inputs, so i am trying in different method using for..in loop with object:
const ResumeGenValues = {
fullNameT: "name",
phoneNumberT: "phone",
mailT: "email",
addressT: "address",
linkedInT: "linked-in",
objectivesT: "objectives",
workExperienceT: "work-experience",
academicQualificationT: "academic-qualification",
};
for (const key in ResumeGenValues) {
const GenEl = document.getElementById(key).value;
document.getElementById(ResumeGenValues[key]).innerText = GenEl;
}
In above i prepared an object with inputelement => templateElement to paste.
I am facing error like:
Uncaught TypeError: Cannot read properties of null (reading 'value')
How i can fix this error?