Jump to content
Fórum Script Brasil
  • 0

Como mudar o valor de um Input para uma variavel


Question

Então, eu estava tentando fazer um código que você ao clicar um botão, o script salva os dados inseridos no localStorage, após você sair do site, você pode voltar e ele busca os dados que foram salvos. A parte de salvar funcionou, mas quando eu clico no de puxar os dados, aparece "undefined"

<html>
    <head>
        <script>
            function loadInfos(){
                var IMail = localStorage.email.value;
                document.getElementById("email").value += IMail;
            }
            
            function saveInfos(){
                var IEmail = document.getElementById("email")
                localStorage.email = IEmail.value;
            }
        </script>
    </head>
    <body>
        <input id="email" type="text" placeholder="Email...">
        <br>
        <button id="saveAll" onclick="saveInfos()">Salvar Infos</button>
        <button id="loadAll" onclick="loadInfos()">Carregar Infos</button>
    </body>
</html>
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149405
    • Total Posts
      645894
×
×
  • Create New...