本地存储无法使用下拉菜单

时间:2012-11-11 20:03:37

标签: storage local

我在将数据保存到存储时遇到问题。

我正在使用文本字段和下拉菜单。

文本字段工作正常,保存但下拉菜单不起作用。

正如您所看到的,我正在使用html 5中的本地存储来保存所有内容

有谁知道问题是什么?

Woonplaats和favomuziek有下拉菜单

$(document).ready(function(){ 
    if (!window.localStorage){
        function createCookie(name,value,days) {
            if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
        }

        function readCookie(name) {
            var result = ""
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                    if (c.indexOf(nameEQ) == 0){
                        result = c.substring(nameEQ.length,c.length);
                    }else{
                        result = "";
                    }
                }
                return(result);
            }
            localStorage = (function () {
            return {
                setItem: function (key, value) {
                    createCookie(key, value, 3000)
                },

                getItem: function (key) {
                    return(readCookie(key));
                }
            };
        })();
    }

    load_settings();

    $('#gebruikersprofiel').submit(function(event){
        event.preventDefault();
        save_settings();
    });
});

function save_settings(){
    localStorage.setItem("voornaam", $("#voornaam").val());
    localStorage.setItem("achternaam", $("#achternaam").val());
    localStorage.setItem("woonplaats", $("#woonplaats").val());
    localStorage.setItem("favomuziek", $("#favomuziek").val());

    apply_preferences_to_page();
}

function apply_preferences_to_page(){
    $("body").css("voornaam", $("#voornaam").val());
    $("body").css("achternaam", $("#achternaam").val());
    $("body").css("woonplaats", $("#woonplaats").val() );
    $("body").css("favomuziek", $("#favomuziek").val() );
}

$(document).ready(function(){

    if (!window.localStorage){
        function createCookie(name,value,days) {
            if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
        }

        function readCookie(name) {
            var result = ""
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0){
                    result = c.substring(nameEQ.length,c.length);
                }else{
                    result = "";
                }
            }
            return(result);
        }
        localStorage = (function () {
            return {
                setItem: function (key, value) {
                    createCookie(key, value, 3000)
                },

                getItem: function (key) {
                    return(readCookie(key));
                }
            };
        })();
    }

    load_settings();

    $('#gebruikersprofiel').submit(function(event){
        event.preventDefault();
        save_settings();
    });
});

function save_settings(){
    localStorage.setItem("voornaam", $("#voornaam").val());
    localStorage.setItem("achternaam", $("#achternaam").val());
    localStorage.setItem("woonplaats", $("#woonplaats").val());
    localStorage.setItem("favomuziek", $("#favomuziek").val());

    apply_preferences_to_page();
}

function apply_preferences_to_page(){
    $("body").css("voornaam", $("#voornaam").val());
    $("body").css("achternaam", $("#achternaam").val());
    $("body").css("woonplaats", $("#woonplaats").val() );
    $("body").css("favomuziek", $("#favomuziek").val() );
}

0 个答案:

没有答案