Php 使用Ajax将下拉列表转换为输入文本框
对不起,这个标题 如何将此代码从下拉列表修改为input textbox,以便从getCustomer.php代码填充input textbox,而不是填充下拉列表Php 使用Ajax将下拉列表转换为输入文本框,php,jquery,ajax,Php,Jquery,Ajax,对不起,这个标题 如何将此代码从下拉列表修改为input textbox,以便从getCustomer.php代码填充input textbox,而不是填充下拉列表 function getOrgCodes() { $.ajax({ url: 'getCustomer.php', dataType: 'json' }) .done(function(orgInfo) { $(orgInfo).each(function(i,
function getOrgCodes() {
$.ajax({
url: 'getCustomer.php',
dataType: 'json'
})
.done(function(orgInfo) {
$(orgInfo).each(function(i, orgdisplay) {
$('<option>').val(orgdisplay.ORGANIZATION).text(orgdisplay.ORGANIZATION).appendTo( $('#deptId') );
})
});
}
函数getOrgCodes(){
$.ajax({
url:'getCustomer.php',
数据类型:“json”
})
.done(功能(orgInfo){
$(orgInfo).每个(功能(i,orgdisplay){
$('').val(orgdisplay.ORGANIZATION).text(orgdisplay.ORGANIZATION.appendTo($('#deptId'));
})
});
}
将
替换为
函数getOrgCodes(){
$.ajax({
url:'getCustomer.php',
数据类型:“json”
})
.done(功能(orgInfo){
$(orgInfo).每个(功能(i,orgdisplay){
$('').val(orgdisplay.ORGANIZATION).appendTo($('#deptId');
})
});
}
更换后,您不需要该.text(orgdisplay.ORGANIZATION)
.val(orgdisplay.ORGANIZATION)
将在文本框内设置值
请参阅此小型演示:
function getOrgCodes() {
$.ajax({
url: 'getCustomer.php',
dataType: 'json'
})
.done(function(orgInfo) {
$(orgInfo).each(function(i, orgdisplay) {
$('<input type="text">').val(orgdisplay.ORGANIZATION).appendTo( $('#deptId') );
})
});
}