我有一个Select2输入,这是一个文本框,我就是这样做的
<input type="text" class="selectbox" name="selectbox['.$row[0].']" />
我应该像mys value="'.$row[1].'"
一样动态地设置初始值,但它不起作用。
这是我的Jquery设置select2:
$(".selectbox").select2({
placeholder: "Search for a Golf Course",
minimumInputLength: 1,
ajax: {
url: "functions/searchGolfCourses.php",
quietMillis:100,
dataType: 'json',
params: {
method: 'post'
},
data: function (term, page) {
// Data to be sent to the server. Usually it is just the "term"
// parameter (and page if using pagination).
// However, since this API simply echoes back what we send,
return { s: term /* 's' is passed to php as $_POST['s'], this will contains the user input*/
}
},
results: function(data, page) {
//data param === received response from the server. As dataType
//is json, jQuery automatically parses the response into an object.
return { results: data };
}
}
});
知道如何设置Select2输入框的初始值吗?提前谢谢