Setting Value for <Select> object

Setting Value for <Select> object

Hello:

I'm trying to populate a <Select> object with the value from a user's record. Following is my current attempt:

  1. var var_ClientType = <? echo json_encode($ClientType)?>;
  2. $(document).ready(function() {
  3.     //===================== POPULATE Drop down List =================
  4.     $.getJSON('select_orgtype.php', function(data) {
  5.         var select = $('#orgType');
  6.         console.log("Var ClientType: " + var_ClientType);
  7.         $("#orgType option:text=" + var_ClientType +"").attr("selected", "selected");        
  8.         $.each(data, function(i, value) {
  9.             $('#orgType').append($('<option>').text(value.ClientType).attr('value', value["0"]));
  10.         });
  11.         // $("#orgType").val(var_POST['orgType']); // This line will repopulate field if there are posting errors
  12.     });
  13. }); // END Document Ready Function
Something is wrong. The list within $.each(data, function(i,value) constructs just fine.

But, the <option> is not populating with var_ClientType.

var_ClientType displays in the console.log, so I know the variable is picking up the value. For some reason, my script is not assigning this value to the orgType <option>.

Any assistance is greatly appreciated.

Thanks Much:

Pavilion