【发布时间】:2017-09-01 06:19:33
【问题描述】:
我想将按钮值从模态传递到主窗口的输入值。
$('#pickCustomer').click(function() {
var id = $("#customerID").val();
var name = $("#pickCustomer").val();
$("#kodep").val(id);
$("#namap").val(name);
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="width:32%;min-height:400px;border:1px solid #ccc;border-radius:5px;float:left;padding:1%;">
<table>
<tr>
<td>Customer Name:</td>
<td>
<input id="kodep" name="kodep" type="hidden" value="">
<input style="float:left;width:75%;margin-right:7px;" id="namap" name="namap" type="text" value="">
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#customertable">Search</button>
</td>
</tr>
</table>
</div>
<div style="width:80%;left:30%;display:none;" id="customertable" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<table id="tablehasil" class="display" style="width:100%;">
<thead>
<tr>
<th>Customer ID</th>
<th>Name</th>
<th>Address</th>
<th>Telp</th>
</tr>
</thead>
<tbody>
<tr>
<td>1001<input id="customerID" type="hidden" value="1001"></td>
<td><button id "pickCustomer" style="background:none;border:none;font-size:13px;" value="test" data-dismiss="modal">testing</button></td>
<td>USA</td>
<td>0000000000</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
当我点击搜索按钮时,出现一个模态弹窗,有一个订阅者列表,我使用dataTable js对其进行排序。
当我单击模式弹出窗口中的按钮(客户名称)时,输入名称未填充我想要的值,并且我在 chrome 控制台上看不到任何错误
【问题讨论】:
标签: javascript jquery bootstrap-modal