简体   繁体   English

如何使用Bootstrap Modal对话框并获取返回值?

[英]How I can use a Bootstrap Modal Dialog and get the return values?

I want to create a Modal Dialog with Bootstrap. 我想用Bootstrap创建一个模式对话框。 I am new in Bootstrap. 我是Bootstrap的新手。

how this: 如何:

在此处输入图片说明

How I can do this and how I get the values from the textfield back. 我该如何做以及如何从文本字段中获取值。

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以延迟在Bootstrap 3中显示模式对话框吗? - Can I delay the showing of a modal dialog in Bootstrap 3? 引导角模态对话框:无法从select返回值 - bootstrap-angular modal dialog: can not return value from select 如何多次使用引导模式? - How can I use a bootstrap-modal multiple times? 如何在另一个 html 页面中使用引导模式? - How I can use bootstrap Modal in another html page? 在asp.net中使用引导程序的对话框模态中的Gridview onclick将值返回到模态父页面Webforms - Gridview onclick in dialog modal with bootstrap in asp.net return values to modal father page webforms 无法获得简单的Twitter Bootstrap模式对话框弹出 - can't get simple twitter bootstrap modal dialog to popup 调整大小超过最大大小后,如何防止关闭Bootstrap模式对话框? - How can I prevent the closure of my Bootstrap modal dialog when I resize past its maximum size? 我如何获得模态中的元素宽度/高度(bootstrap) - How can i get element width / height in modal ( bootstrap ) 我怎样才能使这个React Bootstrap Modal正常工作? - How can I get this React Bootstrap Modal Working properly? 如何关闭Bootstrap中的模式框? - How can I get my modal box in Bootstrap to close?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM