<script>
/* to populate list of value in dropdown via ajax */
function populateSectionsList(id)
{
var idval = id;
var setOptTemp = "<option value='%d'>%s</option>";
var html = "<option value=''>-- Select --</option>";
$.ajax({
type:'post',
url:'http://localhost/myproject/ajaxurl',
data:{'id':idval, 'action':edit},
error:function(){
alert('You have error. Please try again');
},
success:function(data){
var optionList = $.parseJSON(data);
$.each(optionList, function(i, optDetails){
html += setOptTemp.replace('%d', optDetails.id).replace('%s', optDetails.name);
});
$('#dropid').html(html).show();
}
});
}
</script>
//myprojet/ajaxurl.php
<?php
foreach($dropListArr as $value)
{
$dataArr[] = array('id' => $value['id'], 'name' => $value['textname']);
}
?>
Thursday, July 24, 2014
Populate/change list of value in dropdown/select box via ajax
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment