in the console showing an error message on function that jquery.min.js:2 Uncaught TypeError: Cannot set property 'onchange' of undefined at HTMLDocument.
$(document).ready(function() { function change() { var form = this.form, Name_of_comp = form.elements.Name_of_comp, crr = $('.p1').hide(), icss = $('.p2').hide(); if (Name_of_comp.value == 'Capacitor') { crr.show(); } else if (Name_of_comp.value == 'Resistors') { crr.show(); } else { icss.show(); Name.value = ' '; } } var form = document.getElementById('add_name'); form.elements.Name_of_comp.onchange = change; form.elements.Name_of_comp.onchange(); })
> front end <td><select class="form-control" onchange="change()" id="dropdown1" name="Name_of_comp[]"> <option value="">Select</option> <option value="Capacitor">Capacitor</option> <option value="Resistors">Resistors</option> <option value="IC">IC's</option></select>
2.1m questions
2.1m answers
60 comments
57.0k users