メインウィンドウのボタン値をモーダルから入力値に渡したいとします。 ボタンの値をモーダルから渡す
私は、検索ボタンをクリックし
$('#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>
私はモーダルポップアップにあるボタン(顧客名)をクリックすると、入力された名前は、私が欲しいの値で満たされていない、と私はあなたがしているクロームコンソール
重複IDについて言及してくれてありがとうございます。あなたの提案通りに私は変わります。しかし、Andrew Halpernの答えによると、 "pickCustomer"クラスの等号が見つからない – Gumilar
@ Gumilar私はそれに気付かなかった。私は不足している '='を追加するために私の答えを編集しました。 – Titus