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

252
Views
How to reset or set to default selected <option> in <select> after closing the modal

Modal:

<div class="modal fade" id="group_form" data-backdrop="static" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
         <div class="modal-content">
              <div class="modal-body">
                 <select id="status" class="form-control">
                     <option value="1">Active</option>
                     <option value="0" >Disabled</option>
                     <option value="2" >Custom</option>
                 </select>
              </div>
              <div class="modal-footer">
                   <button type="button" class="btn btn-primary save_button add_group"><i class="fas fa-save" aria-hidden="true"></i><span id="save_button_span"> Add</span></button>
                   <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fas fa-window-close" aria-hidden="true"></i> Cancel</button>
              </div>
         </div>
    </div>
</div>

Steps:

  1. After clicking modal select "Custom"
  2. Close modal
  3. Re-open Modal
  4. The "Custom" is still selected instead of the first "Active"

How to reset selected option or make it to default again after I close then reopen again the modal in JS?

I tried to add $("#status").val(''); or $("#status").val('0'); and I also tried to add selected="" on the html and still nothing

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

0

Reset value of select option on Bootstrap modal hidden event

$("#group_form").on("hidden.bs.modal", function () {
   //reset values here. eg
   $(document).find("#status").val('0')
   //or
   $("#status").val('0');
});
about 4 years ago · Juan Pablo Isaza Report

0

Use this method to select:

$(document).find("#status").val('0')
about 4 years ago · Juan Pablo Isaza Report

0

// Regular Javascript : 
document.getElementById('status').selectedIndex = 0

// jquery :
$('#status').prop('selectedIndex', 0);
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!