Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Uncaught ReferenceError: getBiobank is not defined at HTMLSelectElement.onclick (Rails)

I am using Rails MVC project. I have a javascript function defined as follows in assets/application.js

    function getBiobank(){
        var biobank = document.getElementById('biobank');
        var cohort = document.getElementById('cohort');
        var biobank_selectedValue = biobank.options[biobank.selectedIndex].value;
        if (biobank_selectedValue == 'Healthcare Embedded Biobanking' || biobank_selectedValue == 'BMB-CCC' || biobank_selectedValue == 'UKSH Clinic Consent' || biobank_selectedValue == 'BMB-GYN' ){
        cohort.options.length = 0;
        cohort.options[0] = new Option('--Select Cohort',' ')
        }
    }

And in my view, _form.html.haml file I have the following

%h3 Basic
.form-group{class: ("has-error" if @transfer_request.errors.has_key?("Access requested to"))}
  = f.label "Access requested to", class: "control-label"
  %br
  Biomaterial #{f.check_box :access_biomaterial}
  Data #{f.check_box :access_data}
  = f.error "Access requested to"
= f.input :project_title
= javascript_include_tag "application", "data-turbolinks-track" => true
= f.input :biobank, collection: TransferRequest.biobanks.keys, prompt: 'Select biobank', :input_html => {:onclick => "getBiobank()", :class => "stext"} 

When I start the server and check click the drop down list, I get the error in browser console as follows

Uncaught ReferenceError: getBiobank is not defined     at HTMLSelectElement.onclick

Is this a scoping issue?. Any hints would be helpful. Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!