EasyUI Forum
May 08, 2024, 09:06:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to add dynamically combobox from database  (Read 5339 times)
sky_proj
Newbie
*
Posts: 24


View Profile
« on: March 21, 2019, 08:44:32 PM »

i want add combobox-easyui dynamically into my page, when i refresh will read my database and show combobox-easyui

Code:
<html>
<script>
$(document).ready(function(){
$.ajax({
async: false,
type: "POST",
url:"testFunc.php",
data: "proses=1",
dataType: "json", 
success: function(data) {
document.getElementById('mybody').innerHTML =data[0].model;
},
error : function() {
},
complete: function() {
}
});
});
</script>
<body>
<div id="mybody">

</div>
</body>
</html>
Code:
testFunc.php
if (isset($_POST)){
$qstring = "select * from coba";
$rs = mysqli_query($conn_login,$qstring);

$items = array();
while($row = mysqli_fetch_object($rs)){
array_push($items, $row);
}
echo json_encode($items);
}
Code:
table coba just 1 record and 1 field with name "model" as text type
model field contain :
<input name="dataku" class="easyui-combobox" data-options="
valueField: 'label',
textField: 'value',
data: [{
label: 'java',
value: 'Java'
},{
label: 'perl',
value: 'Perl'
},{
label: 'ruby',
value: 'Ruby'
}]" />

the problem my page just show textbox standar html not combobox-easyui, plase help me how to fix this
Thanks
Logged
jahangir
Jr. Member
**
Posts: 51



View Profile Email
« Reply #1 on: March 21, 2019, 11:23:57 PM »

EasyUI controls can't be creaded by just appending the html tags after DOM is fully loaded, you have to re-create it with the javascript after appending html tags.

Plese try this in you ajax call success function.

Code:
document.getElementById('mybody').innerHTML =data[0].model;
$("[name='dataku']").combobox();
Logged
sky_proj
Newbie
*
Posts: 24


View Profile
« Reply #2 on: March 22, 2019, 12:27:00 AM »

EasyUI controls can't be creaded by just appending the html tags after DOM is fully loaded, you have to re-create it with the javascript after appending html tags.

Plese try this in you ajax call success function.

Code:
document.getElementById('mybody').innerHTML =data[0].model;
$("[name='dataku']").combobox();

Ok thanks Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!