jquery, javascript, update dropdown list options upon focus but retain selected value
<p>Brain not working right now. Someone help me fill in the blanks here.</p>

<p>Need to select the currently selected value, repopulate the options, and then select the previous selection if it's still in the list.</p>

<p>To make it easier, the new value and previously selected value will have the same name attribute assuming it's still in the list after updating, and names will always be unique for the list of options.</p>

<pre><code>//assume Options is a globally defined var for this example with format: 
// [{"display":"something", "value": "something's value"}, etc.. ]
function LazyLoadOptionsIntoSelect($select, options)
{
    //get current option


    //repopulate options
    $select.html("");
    $("&lt;option&gt;").text("--Select a File--")
                .appendTo($select);
    $.each(options, function()
    {
        var item = this;
        $("&lt;option&gt;").attr("name", function () { return item.display; })
                .val(function () { return item.value; })
                .text(item.display)
                .appendTo($select);
    });

    //select previously selected option if still in list

}

$(".lazyloadedselect", "#context").live("focus", function() 
{  
    LazyLoadOptionsIntoSelect($(this), Options);
});
</code></pre>

<p>EDIT: mistake in my code, unrelated to the problem, but still wrong</p>
