尽管页面正在刷新,但仍保存输入值

时间:2016-12-20 21:44:46

标签: javascript html forms cookies input

我是一名新程序员,我对学习JavaScript非常感兴趣。我正在制作一个用户输入金额的输入框。我希望它保存到用户nextTime编辑/更新它,但我很难做到。我一直在互联网上寻找这样的一个月,但找不到我理解的东西。我知道一种使用Cookies的方法,但我真的不知道如何编写cookie,我只需要一些提示并帮助完成。 感谢。

HTML

<form id="update" onsubmit="return false" method="post">
    <td><input class="rateContainer" value="Rate" disabled></td>
    <td><input type="number" id="rate"></input></td>
    <td><input type="submit" value ="Update" onclick="Update();" /></td>
</form>

JAVASCRIPT

function Update() {
    var Update = document.getElementById("rate").submit;
}

2 个答案:

答案 0 :(得分:1)

不要使用cookies。使用sibling(X,Y) :- mother(Out1,X), father(Out2,X), mother(Out1,Y), father(Out2,Y). https://developer.mozilla.org/en/docs/Web/API/Window/localStorage

答案 1 :(得分:1)

参见localStorage:

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.example.mrnobody.firebasetutorial"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner         "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro'
        }
    }


        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-    core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-database:9.0.2'
    compile 'com.google.firebase:firebase-crash:9.0.2'
    compile 'com.google.firebase:firebase-auth:9.0.2'
    compile 'com.firebase:firebase-client-android:2.5.2'
}
apply plugin: 'com.google.gms.google-services'