Why Javascript is throwing an error on the selected index value [closed]

I have the code where i am doing select from one and on the basis of that, it will load a second select, but i am getting errors, once such error is:

if (document.forms[0].TwoSelectsRelated1.options[menuNum].value == '') return;

Error is:

Uncaught TypeError: Cannot read properties of undefined (reading 'options')

and this is my complete javascript, i am doing a 3 related selects here