如何使用Jquery将值附加到选项标签[关闭]

i mean, i wanted to retrieve the '$id' and '$name' from database (phpMyadmin) and append those values to my option tag using jQuery. i want the '$id' as the option value and the '$name' as option text. please if any kind hearten people out there, help me out..

Its Easy

HTML

Following is Your select tag

<select id="SelectTest">

</select>

Script

Suppose following is success function of your ajax call

success: function(data) {
         $('#SelectTest').empty();
         var InnerElement='';
         if(data.d.length>0)
          {
             $.each(data.d,function(i,Info){
              InnerElement+='<option value="'+Info.id+'">'+Info.name+'</option>'
             });
             $('#SelectTest').append(InnerElement);
          } 
      }