Keep selected option (form/select) after refresh

Die*_*nto 1 javascript php jquery smarty

Possible Duplicate:
Html select option lost data after submit

I have a select menu that should keep the selected option after the page refresh. This is the example:

<select id="form_frame" name="frame" onchange="getData(this);"/>
   <option value="data1" selected="selected">Data 1</option>
   <option value="data2">Data 2</option>
</select>
Run Code Online (Sandbox Code Playgroud)

函数getData只是向用户提取信息.

我正在使用Smarty/php作为动态内容.

欢迎咨询,谢谢!

ade*_*neo 8

如何使用本地存储:

$(function() {
    if (localStorage.getItem('form_frame')) {
        $("#form_frame option").eq(localStorage.getItem('form_frame')).prop('selected', true);
    }

    $("#form_frame").on('change', function() {
        localStorage.setItem('form_frame', $('option:selected', this).index());
    });
});
Run Code Online (Sandbox Code Playgroud)

小提琴