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

122
Views
How to set a value in a bootstrap modal and then pass it in a disabled textbox?

I would like to set a value via a form in a modal and have that value reflected on a disabled textbox in the main screen. What are the best options out there?

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

0

It can make work using jQuery with the help of event handler

Handle click event of modal dialog, pass data by selecting #Id into modal and show it

Something like.,

$(document).on("click", ".open-modalDialog", function () {
     var mytxtInput1Id = $(this).data('txtInput1');
     $(".modal-body #txtInput1").val( mytxtInput1Id );
     //you have call modal to open here
     $('#addModalDialog').modal('show');
});
about 4 years ago · Juan Pablo Isaza Report

0

Assuming this is bootstrap5:

It seems like you should only get the value after the modal closes... which is what the function attached to myModalEl.addEventListener does.

event.target typical returns the element that has the event listener attached to it, but like I said in the comments in the code below, if it doesn't, then there are a million and one different ways to do so.

var myModalEl = document.getElementById('myModal');
myModalEl.addEventListener('hide.bs.modal', function (event) {
  // getElementsByName returns a list of elements, so be sure to select an element to perform on
  document.getElementsByName("name_of_hidden_element")[0].value = event.target.getElementsByName("name_of_element_inside_of_modal")[0].value
  //event.target.... should work to get the element from inside the modal, but if it doesn't there are several other ways to do so.
});
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!