避免存储数据

时间:2018-08-27 08:23:53

标签: javascript forms session-storage

嗨, 我想知道如何避免每次验证表单时覆盖在sessionStorage中记录的数据。我想每次发送时保留所有数据 预先感谢您的帮助!

document.getElementById('submitNewRestaurant').onclick = function register() {

   if(typeof sessionStorage!='undefined' && JSON) {
        var restaurant = {
            restaurantName:document.getElementById('newName').value,
            adresse:document.getElementById('newAddress').value
        };
        sessionStorage.setItem('coord',JSON.stringify(restaurant));

}


    document.getElementById('submitbtn').onclick  = function register() {


    if(typeof sessionStorage!='undefined' && JSON) {
        var resto= {
            fullcomment:document.getElementById('fullcomment').value,
        };
        sessionStorage.setItem('view',JSON.stringify(resto));

    }


$(function () {

            $("#submitbtn").click(function () {
                var item = $("#numberstars option:selected").text();
                sessionStorage.setItem("stars", item);
            });
            sessionStorage.setItem('stars',JSON.stringify(item));

       });

1 个答案:

答案 0 :(得分:0)

没关系,我发现了,谢谢!:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.test"
    minSdkVersion 18
    targetSdkVersion 26
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.hbb20:ccp:2.2.2'                        // phone number validator
}

}