I have a list of inputs in a form, each with their own incremented id: Note0, Note1, Note2, Note3, Note4a, Note4b, Note5, … They are of type text or checkbox (as are Note4a and Note4b in the first sentence).
I have a textbox and wish to capture the input values and insert them into the textbox. I’m having trouble referencing the inputs by id.
For input type of text, I used:
if (form.input.id === Note3)
For input type of checkbox, I used:
if (form.input.id === Note4a && input.checked)
(If the checkbox is not checked, I don’t want to insert its value into the textbox.)
Outside of the function at the top of the js page I declare the form and id’s thusly:
var form = document.getElementById('my-form');
var input;
var Note0, Note1, Note2, Note3, Note4a, Note4b;
The error I am getting is: “TypeError: form.input is undefined”
Are you sure that you are actually assigning values to the Note variables at some point and not leaving them all undefined? You haven’t included those assignments in the code you posted.