Sunday, 11 November 2018

sort local storage and display results

I have an accounting list at http://verlager.com (google chrome browser required) that I want to sort by ID's P1-P48 How can this be done?

I want to populate the form such that ID variable P1 to P48 is alphabetized and the accompanying IDs E1 to E48 and X1 to X48 have the correct values.

original:

<input id = "P1">Baker, Clifton</input><input id = "E1" />
<input id = "P2">Abercombrie, Saul</input><input id = "E2" />
<input id = "P3">Charles, Ray</input><input id = "E3" />

after processing:

<input id = "P1">Abercombrie, Saul</input><input id = "E1" />
<input id = "P2">Baker, Clifton</input><input id = "E2" />
<input id = "P3">Charles, Ray</input><input id = "E3" />

STORE THE INPUT VARIABLES:

localStorage.setItem("SP1", document.getElementById("P1").value);
localStorage.setItem("SE1", document.getElementById("E1").value);
// ...more of the same
localStorage.setItem("SP48", document.getElementById("P48").value);
localStorage.setItem("SE48", document.getElementById("E48").value);

Put the object into storage (this may be better)

localStorage.setItem('SP1', JSON.stringify(document.getElementById("P1").value)));
localStorage.setItem('SE1', JSON.stringify(document.getElementById("E1").value)));

HERE I WANT TO SORT THE LOCAL STORAGE USING JSON.parse(); AND SORT THEM ALPHABETICALLY BY NAME (P1-P48)

RETRIEVE THE LOCAL STORAGE VARIABLES:

document.getElementById("P1").value=localStorage.getItem("SP1");
document.getElementById("E1").value=localStorage.getItem("SE1");



from sort local storage and display results

No comments:

Post a Comment