walid mahmoud
Published in : 2022-02-28
Hi all
I try to call a javascript function from a separate file, it gives me an undefined function:
I used this code in the blade file and included the js file at the bottom of the blade file
select name=service_id id="service_id" onChange="displaycategories(this.value)">
<script src="{{ asset('js/services.js') }}"></script>
in the service.js file I have the displaycategories function
$(document).ready(function() { function displaycategories(name) { // CODE }});
it gives me this error
Uncaught ReferenceError: displaycategories is not defined at HTMLSelectElement.onchange (760232:303:74)
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Eslam Zedan Date : 2022-02-28
Best answers
8
Best answers
8
You need to move the function outside
$(document).ready(function(){…})
and before select Tag element