[英]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">×</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.