Clicking Twice in Select to Get Option List

Clicking Twice in Select to Get Option List

  1. <select id="selectid">
  2.   <option></option>
  3. </select>
  1. var valArray = data.valarray; // data is coming in correctly from an ajax call
    $('#selectid).children('option:not(:first)').remove();
  2. // selfld are defined correctly
    for (var i = 0; i <= valArray.length - 1; i++) {
      $('#selectid).append('<option value="' + valArray[i][selfld] + '">' + valArray[i][selfld] + '</option>');
    }

When I view the select list and click on it, the above code runs inside of an on focus and the new option values are coming in correctly, but the selection list is NOT extended.  I have to click again to get the dynamically-generated option list.  Is there a way to show the option list right after they are generated ?