How to load saved form in localstorage in a table?

Asked

Viewed 314 times

0

I need a form saved on localstorage be uploaded to another page, within a table, but I don’t know exactly how to do this, the most I can is to be uploaded to the same page of the form, but this way only loads the last saved data.

Code using:

function carregarDados() {
    if (localStorage.length > 0) {
        $("#tit_monografia").val(localStorage.getItem("tit_monografia"));
        $("#nome_autor").val(localStorage.getItem("nome_autor"));
        $("#nome_orientador").val(localStorage.getItem("nome_orientador"));
        $("#area").val(localStorage.getItem("area"));
        $("#ano").val(localStorage.getItem("ano"));
        $("#cidade").val(localStorage.getItem("cidade"));
        $("#resumo").val(localStorage.getItem("resumo"));
    } else {
        alert("Nenhum registro encontrado");
    }
}

Does anyone know how I can solve?

  • 1

    Can you explain "uploaded to another page"? Are you sure the "old" data is there? by the way you’re reading the data gives me an idea that you’re writing over data. It would be nice to use a namespace for your application and use a JSON array for example to store multiple values of each of these fields.

  • 2

    could check how to write in json, that ai vc could add more than one information, and you would treat the localstorage as a data table, you would write as follows: link support: http://www.devmedia.com.br/workcom-html5-local-storage-e-json/29045

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.