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

140
Views
jQuery Selector set select value not working

I have a bootstrap modal, that is offers users to add or edit bank account data.

When I click "Edit" Btn to edit bank data, the modal will set the value to the input value and select the option.

But in the modal, I have two select options, top of the select is to choose bank code,

and when the select changes, it will trigger change function to use ajax to get branch bank list.

So if I want to set the value to the modal, the top select option (bank) can successfully set value,

but the bottom select option (branch) will not successfully set the value to the modal.

My code is:

// Set top select option
$('#selectBankList option[value='+bankName[0]+']').attr('selected','selected');

// Show Modal
addBankModal.show();

// getBranchList
f_getBranchList(bankName[0]);

$(document).ready(function() {
  // Set bottom select option
  $('#selectBranchName option[value='+branchName+']').attr('selected','selected');
});

I've to try putting the set #selectBranchName value to anywhere, but still not working.

So, where is my code wrong?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

$('#selectBankList ').on('change', function(){
    $('#selectBranchName option[value="'+$(this).val()+'"]').attr('selected', 'selected').addClass('active');
});
about 4 years ago · Juan Pablo Isaza Report

0

$('#id attribute[foo="bar"]');

you have not added inner quotes

about 4 years ago · Juan Pablo Isaza Report
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!