2015-05-28 137 views
0

我想用Bootstrap創建一個模態對話框。我是Bootstrap的新手。如何使用Bootstrap模態對話框並獲取返回值?

如何:

enter image description here

我怎樣才能做到這一點,我如何從文本框後面得到的值。

+0

的最佳方式將是開始閱讀的文檔[引導情態動詞(http://getbootstrap.com/javascript/#modals)。你使用的是ASP.NET還是PHP? – Mivaweb

+0

我想用javascript – Tarasov

回答

2

Modal在同一頁上。因此,無論您在頁面中訪問模態內的任何輸入字段。

例如,你有

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

可以使用

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

模態代碼,只需訪問它。這是做

<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> 

-1

嘗試這個辦法:從下拉列表

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

訪問值:

你會碰到這樣的:

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

或者

var plantid = $('.drpplants').get(1).value; 
相關問題