jQuery.fn.textdropdown = function(ul, hiddenfield) {
  with ($(this)) {
    var ulContainer = ul;
    var txtBox = $(this);
    with (ulContainer) {
      find('li').click(function() {
        txtBox.attr('value', $(this).html());
        var id = $(this).attr('id');
        hiddenfield.attr('value', id);
        ulContainer.hide();
      });
      hide();
    } 

    keypress(function() { 
      ulContainer.hide();
    });

    change(function() { 
      ulContainer.hide();
    });

    //wrap('<div class="textdropdown-outer" style="width: ' + width() + 'px; height: ' + (height() + 5) + 'px"></div>');
    css("border", "0");

    txtBox.click(function() {
      var p = parent().parent();
      
      with (ulContainer) {
        css('position', 'absolute');
        css('width',    txtBox.width() - 10);
        css('left',     txtBox.position().left + 5);
        css('top',      txtBox.position().top + txtBox.height() + 5);
        toggle();
      }
    });
  }
}

