![](/img/trans.png)
[英]How to pass the value of the text box to the disabled text box using javascript
[英]How to pass value to text box through javascript
我正在使用bootstrap框架來調用模式對話框,並且我試圖根據單擊的行從mysql表傳遞其唯一值。
我的代碼工作到將值傳遞到對話框的地步,但是我無法使其顯示在文本框中。 h3現在將其顯示在標題中。
這是工作代碼的鏈接。 http://jsfiddle.net/ZEpLV/14/
這是我的代碼:
<div id="com" class="modal hide fade in" style="display: none; ">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h4>Server ID:<h3>PLace for your id</h3>
<div class="modal-body">
<h4>Text in a modal</h4>
<input value="" type="text" name="id" Value="">
<p>You can add some text here.</p>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-success">Call to action</a>
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
<script>
$(".modal-toggler").click(function(){
var _id = $(this).attr("id");
$("#com h3").text(_id);
$("#com").show();
return false;
});
</script>
對於輸入,您需要使用.val()
而不是.text()
$("#com input").val(_id);
給文本字段提供一個ID,並使用文本字段和.val()
ID
$("#text").val(_id);
http://jsfiddle.net/chauhangs/ZEpLV/15/
$(".modal-toggler").click(function(){
var _id = $(this).attr("id");
$("#com h3").text(_id);
$("#text").val(_id);
$("#com").show();
return false;
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.