按下按钮需要增加本地存储值

时间:2015-05-05 07:11:55

标签: javascript count local-storage calculator

我需要将值保存到已存在于localstorage中的localstorage中,并且仅将其增加1

保存

function checkklaar2() {
    a = document.getElementById("eindgetal2").value;
    if (a == "0") {
        window.location.href = 'winnaar2.html';
        var gewonnen2 = localStorage.getItem("setsgewonnen2");
        localStorage.setItem("setsgewonnen2.2", gewonnen2.value + "1");
    } else {}
}

查看:

// Check browser support
if (typeof(Storage) != "undefined") {
    // Store
    // Retrieve
    document.getElementById("result1.1").innerHTML = localStorage.getItem("naamspeler1.1");
    document.getElementById("result2.1").innerHTML = localStorage.getItem("naamspeler2.1");
    document.getElementById("result1.2").value = localStorage.getItem("setsgewonnen1.2");
    document.getElementById("result2.2").value = localStorage.getItem("setsgewonnen2.2");
    document.getElementById("sets").value = localStorage.getItem("setstespelen");
    document.getElementById("sets2").value = localStorage.getItem("setstespelen");
} else {
    document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}

接收时输入,因为它没有显示第2页输入中的值:

HTML:

<h1 style="margin-left:15px;">Speler<div id="result1.1"></div> </h1>
<div class="list-block">
    <ul>
        <div class="list-block">
            <ul>

                <li>
                    <div class="item-content">
                        <div class="item-title label">Sets gewonnen</div>
                        <div class="item-input">
                            <input type="number" id="result1.2">
                        </div>
                    </div>
                </li>


            </ul>
            <ul>

                <li>
                    <div class="item-content">
                        <div class="item-title label">Sets totaal</div>
                        <div class="item-input">
                            <input type="number" id="sets">
                        </div>
                    </div>
                </li>


            </ul>
        </div>
    </ul>
</div>
<h1 style="margin-left:15px;">Speler <div id="result2.1"></div></h1>
<div class="list-block">
    <ul>
        <div class="list-block">
            <ul>

                <li>
                    <div class="item-content">
                        <div class="item-title label">Sets gewonnen</div>
                        <div class="item-input">
                            <input type="number" id="result2.2">
                        </div>
                    </div>
                </li>


            </ul>
            <ul>

                <li>
                    <div class="item-content">
                        <div class="item-title label">Sets totaal</div>
                        <div class="item-input">
                            <input type="number" id="sets2">
                        </div>
                    </div>
                </li>

提前致谢!

1 个答案:

答案 0 :(得分:2)

我认为你正在寻找这样的东西:

sails  --verbose lift

正常情况下,locall存储将所有内容存储为字符串