Add js file in view

The tutorial explains lots for eg this Not Found

Another discussion that may help on embedded javascript for event handlers Learning Javascript for ERPNext