admin管理员组

文章数量:1292111

I want to create a Modal Dialog with Bootstrap. I am new in Bootstrap.

how this:

How I can do this and how I get the values from the textfield back.

I want to create a Modal Dialog with Bootstrap. I am new in Bootstrap.

how this:

How I can do this and how I get the values from the textfield back.

Share Improve this question edited May 28, 2015 at 13:38 amphetamachine 30.6k12 gold badges67 silver badges74 bronze badges asked May 28, 2015 at 11:28 TarasovTarasov 3,69519 gold badges72 silver badges128 bronze badges 2
  • The best way will be to start reading the docs of Bootstrap modals. Are you using ASP.NET or PHP? – Mivaweb Commented May 28, 2015 at 11:34
  • 1 I want use javascript – Tarasov Commented May 28, 2015 at 11:43
Add a ment  | 

2 Answers 2

Reset to default 5

Modal is on the same page. So whatever input field you have inside modal is accessible in your page.

For example you have

<input type="text" id="txtName" />

You can simply access it using

$("#txtName").val(); 

for Modal code. Here it is done

 <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Modal -->
  <div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Modal Header</h4>
        </div>
     <div class="modal-body">
       <input type="text" id="txtname">
    </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  </div>
</div>

try this:

var name = $('#txtname').val();

for access value from dropdownlist:

You'd have something like:

var plantid = $('.drpplants').get(0).value;

Or

var plantid = $('.drpplants').get(1).value;

本文标签: javascriptHow I can use a Bootstrap Modal Dialog and get the return valuesStack Overflow