如何在另一个输入文本上设置另一个值


How Can I Put Another Value On Another Input Text

指的是这个链接:

https://gist.github.com/awgreenblatt/4499835

如果我有3个不同的输入文本,比如:,我该如何输入值

<input id="product_search[1]" type="text" data-provide="typeahead"><br>
<div id="product[1]" style="border-width:1; padding: 5px; border-style: solid"></div><br><br>
<input id="product_search[2]" type="text" data-provide="typeahead"><br>
<div id="product[2]" style="border-width:1; padding: 5px; border-style: solid"></div><br><br>
<input id="product_search[3]" type="text" data-provide="typeahead"><br>
<div id="product[3]" style="border-width:1; padding: 5px; border-style: solid"></div><br>

感谢

取自您提供的链接

var products = [
            {
                id: 0,
                name: "Deluxe Bicycle",
                price: 499.98
            },
            {
                id: 1,
                name: "Super Deluxe Trampoline",
                price: 134.99
            },
            {
                id: 2,
                name: "Super Duper Scooter",
                price: 49.95
            }
        ];
$(document).ready(function(){
   $('#product_search1').val(products[0].name);
   $('#product_search2').val(products[1].name);
   $('#product_search3').val(products[2].name);
});

事实上,我用jsFiddle进行了测试,我的解决方案不会用你的ID。您可能需要重命名输入Id的

jsfiddle。http://jsfiddle.net/KVS5F/